rtconst virtual class sys::Func


Func models an executable function. Functions are typed by a formal parameter list and return value (or Void if no return). Functions are typically defined as method slots on a type, but may also be defined via closures.

An immutable function is one proven to be thread safe:

The definition of a final variable is a variable which is never reassigned after it is initialized. Any variable which is reassigned is considered a non-final variable.

See docLang::Functions for details.


Func bind(List<Obj?> args)

Create a new function by binding the specified arguments to this function's parameters. The new function which takes the remaining unbound parameters.

The resulting function is immutable if this function is immutable and all the args are immutable.


virtual Func^R call(Func^A? a := null, Func^B? b := null, Func^C? c := null, Func^D? d := null, Func^E? e := null, Func^F? f := null, Func^G? g := null, Func^H? h := null)

Optimized convenience for callList for zero to eight parameters.


virtual Obj? callList(List<Obj?>? args)

Dynamically invoke this function with the specified arguments and return the result. If the function has Void return type, then null is returned. The argument list must match the number and type of required parameters. If this function represents an instance method (not static and not a constructor) then the first argument must be the target object. If the function supports default parameters, omit arguments to use the defaults. It is permissible to pass more arguments then the number of method parameters - the additional arguments are ignored. If no arguments are required, you may pass null for args.


virtual Obj? callOn(Obj? target, List<Obj?>? args)

Convenience for dynamically invoking an instance method with specified target and arguments. If this method maps to an instance method, then it is semantically equivalent to callList([target, args[0], args[1] ...]). Throw UnsupportedErr if called on a function which is not an instance method.