expression
::=
literal-expression
| variable-reference
| procedure-call
| TODO
literal-expression
::=
(quote
datum
)
| ’
datum
| constant
constant
::=
number
| boolean
| character
| string
(quote
evaluates to datum
)datum
,
which may be any external representation of a Scheme object.
This notation is used to include literal constants in Scheme code.
(quote a) ⇒ a (quote #(a b c)) ⇒ #(a b c) (quote (+ 1 2)) ⇒ (+ 1 2)
(quote
may be abbreviated as datum
)'
.
The two notations are equivalent in all respects.
datum
’a ⇒ a ’#(a b c) ⇒ #(a b c) ’() ⇒ () ’(+ 1 2) ⇒ (+ 1 2) ’(quote a) ⇒ (quote a) ’’a ⇒ (quote a)
Numerical constants, string constants, character constants, bytevector constants, and boolean constants evaluate to themselves; they need not be quoted.
145932 ⇒ 145932 #t ⇒ #t "abc" ⇒ "abc"
Note that keywords need to be quoted, unlike some other Lisp/Scheme dialect, including Common Lisp, and earlier versions of Kawa. (Kawa currently evaluates a non-quoted keyword as itself, but that will change.)
variable-reference
::=
identifier
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 examples assumes the base library has been imported:
(define x 28) x ⇒ 28
procedure-call
::=
(
operator
operand
…)
operator
::=
expression
operand
::=
expression
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.
(+ 3 4) ⇒ 7 ((if #f + *) 3 4) ⇒ 12