| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
On toplevel, it defines a global binding to a symbol variable. In the first form, it globally binds a symbol variable to the value of expression, in the current module.
(define x (+ 1 2)) x => 3 (define y (lambda (a) (* a 2))) (y 8) => 16 |
The second form is a syntactic sugar of defining a procedure. It is equivalent to the following form.
(define (name . args) body ...) == (define name (lambda args body ...)) |
If the form appears inside a local scope (internal define), this introduce a local binding of the variable.
Note that begin (See section 4.7 Sequencing) doesn't introduce a new scope.
Defines in the begin act as if begin and surrounding
parenthesis are not there. Thus these two forms are equivalent.
(let ((x 0))
(begin
(define (foo y) (+ x y)))
(foo 3))
==
(let ((x 0))
(define (foo y) (+ x y))
(foo 3))
|
srfi-11 - Let-values.
(define-values (lo hi) (min&max 3 -1 15 2)) lo => -1 hi => 15 |
define, but that the compiler assumes
the value of variable won't change and generates
optimized code.
An error is signalled when you use set! to change the value
of variable. It is allowed to redefine variable,
but a warning is printed.
Expression is evaluated in the current module.
The second form is merely a syntactic sugar of:
(define-in-module module variable (lambda formals body ...)) |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |