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

Re: constant folding/smashing



	
    Date: Fri, 10 Jun 88 11:32 EDT
    From: ELIOT@cs.umass.edu
    
	What about constant hash-tables?  No variety of QUOTE can build
	a constant hash table because there is no notation for them.
	(I don't count #.(make-hash-table...) because it's so gross.)

Once again, I will state that the problem is not notation.  QUOTE
cannot cons its argument into RO-space because the argument has ALREADY
BEEN CONSED.  All QUOTE can do it to cons in RO-space an EQUAL COPY of
its argument and return that copy.  But there is NO SUCH THING as an
EQUAL "COPY" of a hashtable.  It doesn't matter that its gross, it
just won't work.

	In general I like the idea of quoted constants being read-only,
	because it ensures that the semantics of a function at run-time
	are apparent from its textual representation as code.  If constants
	are not read-only then:
	
	(defun foo ()
	    '(a b c))
	
	Really means
	
	(defun foo ()
	    G00047)
	(setq G00047 '(a b c))

Funny, this is the semantics that most Lisper's have as their initial
mental model (and I assume find the most intuitive).  It is also the
semantics of all (?) CL interpreters.  QUOTE MUST have the same
behavior in the compiler and the interpreter.  To do otherwise is to
introduce a compiler/interpreter incompatibility as confusing and
error-prone as the SPECIAL variable incompatibility used to be.  Agreed?

If you want to suggest that the interpreter should be changed to make
QUOTE return a RO-EQUAL-copy of its arg when possible*** (as I think JonL
may have been suggesting?), then consider what a pain it will cause at
the top-level:

> (setf foo '(1 2 3))
(1 2 3)
> (push 0 foo)
>>>>> Error ...

Instead, you'll have to do:

> (setf foo (list 1 2 3))
(1 2 3)
> (push 0 foo)
(0 1 2 3)

A lot of Lisp textbooks will have to be rewritten!

-- Nick

*** Actually, the interpreter's handling of self-evaluating forms will
have to be changed too.