John Thingstad <jpthing@online.no> wrote:
+---------------
| skrev Pascal J. Bourguignon <pjb@informatimago.com>:
| > Language-wise, Common Lisp is 17 special operators, and an evaluation
| > model (lambda, closures, environments). This is a very small kernel.
|
| actually 26.. see PCL. Now Scheeme has only 6
+---------------
Well, R4RS Scheme actually had *9* primitive or special forms ["essential
syntax"] if you assume that there is some sort of macro system available
[one is proposed in the appendix, though not technically part of R4RS]:
{variable reference}
quote
{procedure call}
lambda
if
set!
define
begin
define-syntax [or defmacro or define-macro (see below)]
Otherwise, without a macro system you'd have to add the dozen or so
"derived expressions", COND, CASE, AND, OR, LET, etc., as special forms.
[Note that due to the macro system not being part of the formal spec, these
were also called "essential syntax" in R4RS, but weren't really, since all
useful Schemes had *some* kind of macro system, even if just DEFMACRO!]
Aside: DEFINE has to be a primitive special form, since it must be
capable of distinguishing whether it's being used at the top level
(equivalent to a SET!) or as an "internal DEFINE" (equiv. to LETREC),
and thus cannot be specified entirely by DEFINE-SYNTAX.
Similarly, BEGIN must be capable of distinguishing whether it's
being used at the top level, in which case it must propagate
"top-level status" to any DEFINEs within it [much like PROGN does
in CL]. When not at the top level, it could be macro-expanded into
a call of a function ((LAMBDA (ignored) rest...) first-expr), but
that hack doesn't work for preserving top-level status of DEFINEs.
R5RS Scheme formalized the DEFINE-SYNTAX macro system but also added
two local syntax binding forms [think MACROLET], and so ended up with
*11* primitive or special forms:
{variable reference}
quote
{procedure call}
lambda
if
set!
define
begin
define-syntax
let-syntax
letrec-syntax
Listed another way, from R5RS "7.1.6 Programs and definitions" and
"7.1.3 Expressions":
<program> ---> <command or definition>*
<command or definition> ---> <command> | <definition>
| <syntax definition>
| (begin <command or definition>+)
<definition> ---> (define <variable> <expression>)
| (define (<variable> <def formals>) <body>)
| (begin <definition>*)
<expression> ---> <variable> | <literal> | <procedure call>
| <lambda expression> | <conditional> | <assignment>
| <derived expression> | <macro use> | <macro block>
where:
<syntax definition> ---> (define-syntax <keyword> <transformer spec>)
<literal> ---> <quotation> | <self-evaluating>
<derived expression> ---> {all the standard macros, COND, CASE, etc.}
<macro use> ---> (<keyword> <datum>*)
<macro block> ---> (let-syntax (<syntax spec>*) <body>)
| (letrec-syntax (<syntax spec>*) <body>)
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607