pike.git / lib / modules / Function.pmod

version» Context lines:

pike.git/lib/modules/Function.pmod:289:    //! @decl constant arg6;    //! @decl constant arg7;    //! @decl constant arg8;    //! @decl constant arg9;    //! @decl constant arg...;    //! arg<n> will return an instance of @[Arg] that returns the n:th arg.    //! For convenience for c++11 developers _0, _1 etc also works.    //!    //! Note that arg0 is the first argument, not arg1    -  class Expr(function value) +  class Expr(function func, void|bool _splice)    //! Expr(x) returns the result of calling @[x]. -  //! The function will be passed the bind instance and the -  //! list of arguments, in that order. +  //! The function will be passed the list of arguments.    //! -  +  //! If _splice is true, zero or more argument is returned in an array +  //!    //! Function.Placeholder.arg1 is thus more or less equivalent to -  //! @code Expr(lambda(Function.bind b, array args ){return args[1];}); -  //! (however, @[Function.Placeholder.rest] would not know about this usage) +  //! @code Expr(lambda(array args){return args[1];});    {    inherit Base;    protected string _sprintf() {    return sprintf("Expr(%O)",value);    } -  +  mixed value( bind x, array args ) +  { +  return func(args);    } -  +  }       private mapping _cache = ([]);    mixed `[](string name)    {    if( _cache[name] )    return _cache[name];    mixed tmp;    if(sscanf(name, "arg%d", tmp) || sscanf(name, "_%d", tmp))    return _cache[name] = Arg(tmp);    return ::`[](name);    };   }();