[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: need for quoting in Lisp

At first glance it seems odd that Lisp requires quoting while Prolog
and lambda-calculus do not.  The reason is that Lisp attempts to be
it's own meta-language, allowing chunks of code to be treated as data.
This power carries with it the danger that code and data might be
confused, and QUOTE is the way in which the confussion is averted.  To
illustrate very concretely, imagine a Schemelike language which is NOT
it's own metalanguage, in which there are no macros.  For any
construct, we can tell unambiguously whether we have code or data
in our hands, and hence quoting will be unnecessary.

Let's call our emasculated Scheme Scheme0.  In Scheme0, the symbols
manipulated by code will not be used to represent variables.  Rather,
we will have two different kinds of symbols, which both have the
identity property but are distinguished.  The read/print convention I
use will be that v-symbols will be lower case and d-symbols will be
upper case.  V-symbols will never be allowed into data structures
manipulated by code; rather they can only be part of programs

Similarly, we will have two different kinds of cons cells: the cons
cells that make up the lists used to represent function calls and
special forms, and another kind of cons cell used to construct lists
manipulated by Scheme0 programs.  The read/print convention for these
will be that program cons cells use (...) and data cons cells use
[...].  We now have a situation much like that with numbers and strings
in regular lisps: data cons cells can never be used to mean program, so
need not be quoted, and similarly with data symbols.  Semantics by

	Regular Scheme				Scheme0

 (car (append x y))			(car (append x y))

 (car (quote (append x y)))		(car [APPEND X Y])

 (append (f x) (g (quote y))		(append (f x) (g Y) [H Z])
         (quote (h z)))

 (f (lambda (x) (f x (quote (f x)))))	(f (lambda (x) (f x [F X])))

There are many routes to add metarepresentational power to Scheme0.
One is to identify v-symbols with d-symbols, and the same with lists,
thus requiring QUOTE to distinguish constants from code, but allowing
macros to be written.  Another would be to force macros to be written
in another language, say Scheme0-1, which can manipulate both v-data
and d-data, and is written using v-prime-datatypes.  Unfortunately,
this requires more and more datatypes as we move up levels in the
tower.  Thus, a DOLIST macro written to apply to Scheme0 code would be
written in Scheme0-1, but then DOLIST couldn't be used in Scheme0-1
unless you rewrote it in Scheme0-2, etc.  There is a way out of this
dilemma, as with 3LISP, but Lisp has chosen to take the first road and
bite the QUOTE bullet.  It remains to be seen if Prolog will be able to
integrate more natural source to source transformations without going
the same route.