[
declare at the top level {+functions}
header: <;small>^<;/small>{;;name}(\s+{;;parameters})?
parameters: {;;name}?(\s+{;;default})?
defaults: {;;number}|{;;string}
space-separate parameters
declaration start: {;;header}\s*:\s*$
declaration end: <;small>^<;/small>/<;small>$<;/small>
empty return: <<
return value: <<\s*{;;expression}
return parameters are not supported
calling: {;;name}\s*:\s*{;;values}
space-separate values
omit parameter: \s*&\s*
parameterless call: {;;name}!
]
Functions are written at the
unindented top level, {+function declarations}
starting with their name
and ending with a {slash}:
[
[:
fname
...
/
:]
]
Before their actual code body,
their parameters, if any,
are declared, followed by a {colon}:
[
[:
fname
parameters
:
...
/
:]
]
The parameters can each stand
on indivudal lines:
[
[:
fname
param1
param2
param3
:
...
/
:]
]
They also can be space-separated:
[
[:
fname
param1 param2 param3
:
...
/
:]
]
And both ways can be mixed freely:
[
[:
fname
param1 param2
param3
:
...
/
:]
]
In fact, they can even be declared
space-separated after the function name,
and the colon can stand anywhere
(but it must be followed by a line break):
[
[:
fname parameters:
...
/
:]
]
Parameterless functions
also need the colon:
[
[:
fname:
...
/
:]
]
Parameterless functions are called {+call}
by their name, followed by {+function calls}
an {exclamation mark}: {+parameterless functions}
[
[:
fname!
:]
]
Other function calls have a {colon}
instead, followed by space-separated
values for their parameters: {+calling a function}
[
[:
fname:val1 val2 val3
:]
]
You don't need to provide all paramters:
[
[:
fname:val1
:]
]
The remaining paramters will
be empty strings (aka "undefined") {+undefined}
in the called function, {+unset}
unless you declare a {default} value,
as a number or string following the
parameter name and a space character:
[
[:
fname
param1 defaultfor1
param2 defaultfor2
param3 defaultfor3
:
...
/
:]
]
In function calls, you can also
{omit parameters} by writing
an {ampersand} instead:
[
[:
fname:& & val3
:]
]
The omitted parameters then will
get their defaults upon the call.
If you provide more values {+extra parameters}
than there are parameters declared,
the {extra values} will be ignored.
Use {parentheses} for {nested function calls}:
[
[:
functA:Aval1 (functB:Bval1) Aval3
:]
]
This is not necessary, however,
for parameterless sub-calls: {+sub-calls}
[
[:
functA:Aval1 functC! Aval3
:]
]
In the function declaration,
to return from the function
with a {result} value:
[
[:
<<value
:]
]
To just {return}, without a value
(actually returns an empty string),
just write:
[
[:
<<
:]
]
Eas purposefully
does not support {return parameters}.
Calling a nonexistent&;nbsp;function{=nonexistent functions}
simply returns an empty string. {+undeclared functions}
[
JS:
[:
renderNow();
:]
Eas:
[:
renderNow!
:]
]
[
JS:
[:
greeting(hour,name)
:]
Eas:
[:
greeting:hour name
:]
]
[
JS:
[:
greeting(getHour(now(),"UTC+1"),name)
:]
Eas:
[:
greeting:(getHour:now! "UTC+1") name
:]
]
[
JS:
[:
function Hello(){;;
alert("Hello World!")
}
:]
Eas:
[:
Hello:
SAY:"Hello World!"
/
:]
]
[
JS:
[:
function myf(a,b,c=3){;;
return a*b+c
}
:]
Eas:
[:
myf a b c 3:
<<a*b+c
/
:]
]
[
JS:
[:
if(x<3)return
:]
Eas:
[:
?x<3
<<
/
:]
]
[
JS:
[:
if(!usr.ol)return n+" is offline"
:]
Eas:
[:
?usr.ol=0
<<";n is offline"
/
:]
]