31 lines
1.2 KiB
Plaintext
31 lines
1.2 KiB
Plaintext
procedure main() # demonstrate and describe function calling syntax and semantics
|
|
|
|
# normal procedure/function calling
|
|
|
|
f() # no arguments, also command context
|
|
f(x) # fixed number of arguments
|
|
f(x,h,w) # variable number of arguments (varargs)
|
|
y := f(x) # Obtaining the returned value of a function
|
|
|
|
# procedures as first class values and string invocation
|
|
|
|
f!L # Alternate calling syntax using a list as args
|
|
(if \x then f else g)() # call (f or g)()
|
|
f := write # assign a procedure
|
|
f("Write is now called") # ... and call it
|
|
"f"() # string invocation, procedure
|
|
"-"(1) # string invocation, operator
|
|
|
|
# Co-expressions
|
|
|
|
f{e1,e2} # parallel evaluation co-expression call
|
|
# equivalent to f([create e1, create e2])
|
|
expr @ coexp # transmission of a single value to a coexpression
|
|
[e1,e2]@coexp # ... of multiple values (list) to a coexpression
|
|
coexp(e1,e2) # ... same as above but only in Unicon
|
|
|
|
# Other
|
|
|
|
f("x:=",1,"y:=",2) # named parameters (user defined)
|
|
end
|