at:tutorial:basic
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
at:tutorial:basic [2007/04/05 15:11] – elisag | at:tutorial:basic [2007/04/06 08:12] – elisag | ||
---|---|---|---|
Line 1: | Line 1: | ||
< | < | ||
- | **IN PROGRESS!!** | + | **IN PROGRESS: FIRST DRAFT!!** |
- | - TODO: Talk about methods instead of functions? Check iat chapter. | + | - TODO: Adding Table splicing, quasi-quoting? |
</ | </ | ||
====== Functional and Imperative Programming ====== | ====== Functional and Imperative Programming ====== | ||
Line 109: | Line 109: | ||
</ | </ | ||
- | Variables and functions defined locally to functions are only visible in the scope of the function where there were defined. | + | This example also illustrates how a function can be made private by means of lexical scope. |
=== Variable-Length Argument Functions === | === Variable-Length Argument Functions === | ||
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