Anvil | Smiths Smiths | Register Register | Login Login |
Search:
Show links Show tools Show tree | Previous document Next document | njet.org > Anvil > Documentation > Language reference > Expressions > Primaries > Accessors > Calls

Calls

A call calls a callable object (such as a function or method) with a series of parameters:

If the left side of a call expression can be statically bound (to a function or method), then the call will be more effective than in the case of an arbitrary expression. (There might be callbacks involved.)

If the binding is static, then named parameters may be used. These can be given in any order as long as the names are correct and all required parameters are filled in.

A splice operator (@) is used to split a container into function parameters. This is accomplished by getting enumeration from it and "inserting" each returned value into the parameter list.

Special closure call will only take one parameters, an inline function immediately following the callable. This form is provided purely because enclosing parenthesis would look really confusing. However, no other parameters may be given with this form.

The return value of a call depends on the type of the left-side expression.

Function or method
Return value of callable, or undefined if none is returned.
Class type
New instance of a given class (although the use of a new operator is recommended.)
Library class instance
Class dependent, see anvildoc.
Class instance
If callback callbacks _execute is declared, then call will yield the return value of the expression.
Otherwise an exception is generated.

  call-expr :=  identifiercallable "(" parameters ")" 
  call-expr :=  identifiercallable  inline-functionparameter    
  parameters := param ( "," param )* 
  param := [ symbolname "=" | "@" ] expr 
See also  | Primaries  | Accessors  | New operator  | Method invokes  | Grammar
Contributes notes:
Add a note
What's new | Anvil