at:tutorial:basic
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
at:tutorial:basic [2007/04/06 08:08] – * elisag | at:tutorial:basic [2007/04/06 08:11] – adding elisag | ||
---|---|---|---|
Line 149: | Line 149: | ||
As you have probably noticed in the previous examples, | As you have probably noticed in the previous examples, | ||
- | The function name can be thus used to refer the function (without calling it). This will also return a closure to that function. | + | The function name can be thus used to refer the function (without calling it). This will also return a closure to that function. |
+ | < | ||
+ | >def makeCell(val){ | ||
+ | def getter() { val} ; | ||
+ | def setter(v) {val := v}; | ||
+ | [getter, setter] | ||
+ | } | ||
+ | >>< | ||
+ | >def [get, set] := makeCell(42); | ||
+ | >> | ||
+ | </ | ||
+ | |||
+ | This example also illustrates how a function can make public some of its local fields or functions by returning them as its return value. The get and set could be then passed as arguments to other functions such as // | ||
+ | |||
at/tutorial/basic.txt · Last modified: 2020/02/09 22:05 by elisag