Any identifier that is not a syntactic keyword (see section see section Identifiers) may be used as a variable. A variable may name a location where a value can be stored. A variable that does so is said to be bound to the location. The set of all such bindings in effect at some point in a program is known as the environment in effect at that point. The value stored in the location to which a variable is bound is called the variable's value. By abuse of terminology, the variable is sometimes said to name the value or to be bound to the value. This is not quite accurate, but confusion rarely results from this practice.
Certain expression types are used to create new locations and to
bind variables to those locations. The most fundamental of these binding constructs is the
lambda expression, because all other binding constructs
can be explained in terms of lambda expressions. The other binding
expressions (see sections see section lambda expressions, see section Binding constructs, and see section Iteration).
Like Algol and Pascal, and unlike most other dialects of Lisp except for Common Lisp, Scheme is a statically scoped language with block structure. To each place where a variable is bound in a program there corresponds a region of the program text within which the binding is effective. The region is determined by the particular binding construct that establishes the binding; if the binding is established by a lambda expression, for example, then its region is the entire lambda expression. Every reference to or assignment of a variable refers to the binding of the variable that established the innermost of the regions containing the use. If there is no binding of the variable whose region contains the use, then the use refers to the binding for the variable in the top level environment, if any (section see section Standard procedures); if there is no binding for the identifier, it is said to be unbound.
Any Scheme value can be used as a boolean value for the purpose of a conditional test. As explained in section section Booleans, all values count as true in such a test except for #f and the empty list, which count as false. This report uses the word "true" to refer to any Scheme value that counts as true, and the word "false" to refer to any Scheme value that counts as false.
An important concept in Scheme (and Lisp) is that of the external representation of an object as a sequence of characters. For example, an external representation of the integer 28 is the sequence of characters "28", and an external representation of a list consisting of the integers 8 and 13 is the sequence of characters "(8 13)".
The external representation of an object is not necessarily unique. The integer 28 also has representations "28.000" and "#x1c", and the list in the previous paragraph also has the representations "( 08 13 )" and "(8 . (13 . ()))" (see section see section Pairs and lists).
Many objects have standard external representations, but some, such as procedures, do not have standard representations (although particular implementations may define representations for them).
An external representation may be written in a program to obtain the
corresponding object (see
quote, section see section Literal expressions).
External representations can also be used for input and output. The
read (section see section Input) parses external
representations, and the procedure
write (section see section Output)
generates them. Together, they provide an elegant and powerful
Note that the sequence of characters "(+ 2 6)" is not an external representation of the integer 8, even though it is an expression evaluating to the integer 8; rather, it is an external representation of a three-element list, the elements of which are the symbol + and the integers 2 and 6. Scheme's syntax has the property that any sequence of characters which is an expression is also the external representation of some object. This can lead to confusion, since it may not be obvious out of context whether a given sequence of characters is intended to denote data or program, but it is also a source of power, since it facilitates writing programs such as interpreters and compilers which treat programs as data (or vice versa).
The syntax of external representations of various kinds of objects accompanies the description of the primitives for manipulating the objects in the appropriate sections of chapter section Standard procedures.
Go to the first, previous, next, last section, table of contents.