page

functionscall

VERSIONlatest Describe how to call a function

FUNCTIONSCALL

NAME

functionscall - Describe how to call a function

SYNOPSIS

ff(…) - Description of function call

DESCRIPTION

The BNF definition for a function call in sncode is the following:

function call ::= ID ( arguments ) | ID ()

So a function call can have arguments or not!

BNF for argument is :

arguments ::= arguments , argument | argument

Arguments is either one argument or a list of arguments separated by commas.

And finally argument are :

argument ::= ID : mexpressions |
                         mexpressions

mexpressions ::= expressions | array | context

An argument is either a named argument or nor.

A named argument is used to name an argument.

For a named argument or not, we have an mexpressions which can be an array :

[ 1, 2, 3 ... ]

or a context:

{ directory : "tmp", name : "text" }

or an expressions :

1 + 2

EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

res={_{ function f(...) sn_argsn; sn_argsp; endfunction f(1);}}.), q(res={}\[1].));
res={_{ function f(...) sn_argsn; sn_argsp; endfunction f(1,2,3);}}.), q(res={}\[1,2,3].));
res={_{ function f(...) sn_argsn; sn_argsp; endfunction f(1+2*3);}}.), q(res={}\[7].));
res={_{ function f(...) sn_argsn; sn_argsp; endfunction f(1+2*3,1+2*3**4);}}.), q(res={}\[7,163].));
res={_{ function f(...) sn_argsn; sn_argsp; endfunction f(a:1+2*3,1+2*3**4);}}.), q(res={"a":7}\[163].));
res={_{ function f(...) sn_argsn; sn_argsp; endfunction f(a:1+2*3,b:1+2*3**4);}}.), q(res={"a":7,"b":163}\[].));
res={_{ function g(...) "g"; sn_argsn; sn_argsp; return sn_argsp[0] +1 ; endfunction function f(...) "f"; sn_argsn; sn_argsp; endfunction f(a:g(1+2*3),b:1+2*3**4);}}.),
              q(res=g{}\[7]f{"a":8,"b":163}\[].));
res={_{ function f(...) sn_argsn; sn_argsp; endfunction f(a:{x:1,y:2},b:1+2*3**4);}}.), q(res={"a":{"x":1,"y":2},"b":163}\[].));
res={_{ function f(...) sn_argsn; sn_argsp; endfunction f(a:{x:1,y:2},b:[1+2*3**4,9]);}}.), q(res={"a":{"x":1,"y":2},"b":\[163,9]}\[].));

AUTHOR

Written by Pierre Laplante, <laplante@sednove.com>