Next: scheme syntax macros, Up: scheme syntax [Index]
The entries in this section all describe expressions, which may occur in the place of ?expression syntactic variables.
An expression consisting of a representation of a number object, a boolean, a character, a string, or a bytevector, evaluates “to itself”.
145932 ⇒ 145932 #t ⇒ #t "abc" ⇒ "abc" #vu8(2 24 123) ⇒ #vu8(2 24 123)
The value of a literal expression is immutable, Storage model
An expression consisting of a variable is a variable reference if it is not a macro use (see below). The value of the variable reference is the value stored in the location to which the variable is bound. It is a syntax violation to reference an unbound variable.
The following example assumes the base library has been imported:
(define x 28) x ⇒ 28
A procedure call consists of expressions for the procedure to be called and the arguments to be passed to it, with enclosing parentheses. A form in an expression context is a procedure call if ?operator is not an identifier bound as a syntactic keyword.
When a procedure call is evaluated, the operator and operand expressions are evaluated (in an unspecified order) and the resulting procedure is passed the resulting arguments.
The following examples assume the (rnrs base (6))
library has been
imported:
(+ 3 4) ⇒ 7 ((if #f + *) 3 4) ⇒ 12
If the value of ?operator is not a procedure, an exception with
condition type &assertion
is raised. Also, if ?operator
does not accept as many arguments as there are ?operands, an
exception with condition type &assertion
is raised.
NOTE In contrast to other dialects of Lisp, the order of evaluation is unspecified, and the operator expression and the operand expressions are always evaluated with the same evaluation rules.
Although the order of evaluation is otherwise unspecified, the effect of any concurrent evaluation of the operator and operand expressions is constrained to be consistent with some sequential order of evaluation. The order of evaluation may be chosen differently for each procedure call.
NOTE In many dialects of Lisp, the form
()
is a legitimate expression. In Scheme, expressions written as list/pair forms must have at least one subexpression, so()
is not a syntactically valid expression.
Next: scheme syntax macros, Up: scheme syntax [Index]