The cond-expression in Scheme is a special form, but is the else keyword, used as final case in a cond-expression, a special form? Or is it just a reserved keyword that is essentially equivalent to the truth-value #t ?
In the latter case, why cannot I write something like (?eq else #t)?
Is the "else" keyword, used as final case in a cond-expression, a special form in Scheme?
405 Views Asked by Kim Mens At
3
There are 3 best solutions below
0
On
It's part of the syntax of cond and case. R7RS specifies the following syntax:
(cond <cond clause>+)
(cond <cond clause>* (else <tail sequence>))
(case <expression>
<case clause>+)
(case <expression>
<case clause>*
(else <tail sequence>))
It's not defined outside the syntax of these special forms.
The Scheme standards call
else, as used in acondform, auxiliary syntax. R6RS shows one possible implementation ofcondusingsyntax-rules; hereelseis called a <literal>:Note that
elseis not a replacement for#t. A <literal> is an identifier that is used to match input subforms; it is treated as a syntactic keyword within thesyntax-rulesform.