Next: baselib definitions syntax, Up: baselib definitions [Index]
The define
form described in this section is a ?definition
used to create variable bindings and may appear anywhere other
definitions may appear.
The first from of define
binds ?variable to a new location
before assigning the value of ?expression to it.
(define add3 (lambda (x) (+ x 3))) (add3 3) ⇒ 6 (define first car) (first '(1 2)) ⇒ 1
The continuation of ?expression should not be invoked more than once.
Implementation responsibilities: Implementations should detect
that the continuation of ?expression is invoked more than once.
If the implementation detects this, it must raise an exception with
condition type &assertion
.
The second form of define
is equivalent to:
(define ?variable ?unspecified)
where ?unspecified is a side–effect–free expression returning an unspecified value.
In the third form of define
, ?formals must be either a
sequence of zero or more variables, or a sequence of one or more
variables followed by a dot .
and another variable (as in a
lambda expression). This form is equivalent to:
(define ?variable (lambda (?formals) ?body))
In the fourth form of define
, ?formal must be a single
variable. This form is equivalent to:
(define ?variable (lambda ?formal ?body))