diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2017-11-18 19:28:17 -0500 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2017-11-18 19:28:17 -0500 |
| commit | ca345f7565ea10a4081d4a559d87f882af31dc0f (patch) | |
| tree | 14278673582e0666a5cbe8080746cd690f1049b1 /LANGUAGE.rst | |
| parent | a6dcdcad4fd8407cbd67fb1c2d293f0d3be88914 (diff) | |
Varargs for user-defined functions, using the Scheme convention of a dotted pair or a loose symbol.
The ability to bind chunks of code to run in the session when a module is bound.
Diffstat (limited to 'LANGUAGE.rst')
| -rw-r--r-- | LANGUAGE.rst | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/LANGUAGE.rst b/LANGUAGE.rst index 79f8265..36f5793 100644 --- a/LANGUAGE.rst +++ b/LANGUAGE.rst @@ -57,6 +57,19 @@ Forms * Examples: ``; this function is extremely spicy.`` +* Compound forms: conses and dotted pairs + + * An opening ``(``, followed by a head subform, followed by spaces, + followed by a ``.``, followed by a tail subform, followed by a closing + ``)``. + + * Represents a *cons* with the given head and tail. + + * A dotted pair which appears as the head of a dotted pair does not require + an additional dot. + + * Examples: ``(1 . 2)``, ``(1 2 . 3)``, ``(('ll . 'lr) . ('rl . 'rr))`` + * Compound forms: lists * An opening ``(``, followed by a sequence of "subforms" separated by @@ -194,7 +207,10 @@ Lists that begin with one of the following symbols are evaluated specially. procedure value which can be used to apply the newly-defined procedure. * Must include a ``formals`` subform, which is generally a list of argument - names (as symbols). + names (as symbols). If the formals subform is a bare symbol, or a dotted + pair whose tail is a symbol, the function has variable arity, and all + arguments not assigned to a name from the formals list are collected into + a list and bound to that symbol. * May include a sequence of body subforms, which are evaluated in order (as if by ``begin``) whenever the function is applied. @@ -234,6 +250,13 @@ Lists that begin with one of the following symbols are evaluated specially. for the ``+`` function itself, but it illustrates the idea that functions can include other functions. + :: + + (lambda (a . b) b) + + This defines a function which takes one or more arguments, whose + evaluation is the list of arguments other than the first. + * ``define``: A ``define`` form sets the value of a new binding in the current environment. This has two forms: |
