Closure operator now behaves as default argument operator, documentation.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@965 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-06-03 18:33:17 +00:00
parent c5159ebcf7
commit d00beeb55f
11 changed files with 182 additions and 60 deletions
+13
View File
@@ -74,4 +74,17 @@ This can be done by first making a copy, and calling that:
> to_upper("xyz") == "upper case: XYZ"
Note that @real_to_upper@ is called without extra parameters, the @input@ variable is still set from the outer call to the new @to_upper@ itself.
--Default arguments--
It is possible to declare default arguments for functions using the @@@@ operator.
> function := { "argument was: " + arg }@(arg:"default")
If this function is called without the @arg@ argument, then the default value @default@ is used instead.
For example:
> function() == "argument was: default"
> function(arg: "something else") == "argument was: something else"
For determining whether the argument is set only explicit arguments count, not everything in scope, so
> arg := "something else"
> function() == "argument was: default"
Defaults are evaluated at the time the @@@@ operator is evaluated, so they can be used to simulate static scoping.
<div style="text-align:right;">next: <a href="control_structures">Control structures &rarr;</a></div>