Subject: primitive syntax [was: Re: Why CALL/CC is a procedure ]
From: (Rob Warnock)
Date: 9 May 2001 04:13:35 GMT
Newsgroups: comp.lang.scheme
Message-ID: <9dag5f$6oas3$>
David Rush  <> wrote:
| Indeed. Scheme has very little "syntax". define, if, lambda, and set!
| (what am I missing?) very neaarly generate the whole language.

After whitespace & comment elimination, I usually consider there to be
nine pieces of "primitive syntax" -- perhaps "primitive expressions"
is a better term, since that's what's used in R5RS 4.1:

	quoted literals[*]
	procedure call [or application]
	define-syntax [or define-macro, or defmacro, or something equiv.]

plus one that often gets overlooked:

	begin [**]

Those are the minimum that a "toy" Scheme implementation has to implement
in the underlying virtual machine -- the rest can be done with macros.

Though, if you add some non-R5RS primitive reflective procedures to access
the global namespace, "define" can even be done as a macro that expands
to a procedure call something like "(define-global 'var val)" [albeit
making internal-define work properly becomes "interesting" -- you need
another reflective primitive procedure to tell the "define" macro the
context in which it's being expanded (top-level or not)].

Likewise, given that "read" contains the appropriate built-in reader macros
to convert backquote, comma, and comma-at to the canonical S-expr forms,
quasiquotation can be treated as "just" a library macro, handled as other
macros are, by "eval" (presumably also called by "load" and the REPL).


[*] I lump quote with literals, as R5RS 4.1.2 does, since the "quote"
    is always *legal*, just not always necessary (e.g., for numbers,
    strings, chars, or booleans).

[**] Top-level only, for sequences of definitions. A "begin" as a sub-
     expression can always be treated as a macro for a procedure call
     (unless you choose to make the internal implementation of lambda
     take only one body expression, then the "begin" expression also
     has to be primitive, internally at least).

Rob Warnock, 31-2-510
SGI Network Engineering		<URL:>
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA