4.1. Variable References


4.1. Variable References

variable

syntax

returns: the value of variable

Any identifier appearing as an expression in a program is a keyword or variable reference. It is a keyword reference if a lexical or top-level keyword binding for the identifier is visible; otherwise, it is a variable reference. After syntactic extensions have been expanded (see Chapter 8, no keyword references remain, so all remaining identifier expressions are variable references.

 list  #<procedure> (define x 'a) (list x x)  (a a) (let ((x 'b))   (list x x))  (b b) (let ((let 'let)) let)  let 

It is an error to evaluate a top-level variable reference before the variable is defined at top-level, but it is not an error for such a reference to appear within a part of a that has not yet been evaluated. This permits mutually recursive procedures to be defined using top-level bindings.

 i-am-not-defined  error (define f   (lambda (x)     (g x))) (define g   (lambda (x)     (+ x x))) (f 3)  6 




The Scheme Programming Language
The Scheme Programming Language
ISBN: 026251298X
EAN: 2147483647
Year: 2003
Pages: 98

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net