Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!wasatch!defun.utah.edu!sandra
From: sandra%defun.utah.edu@wasatch.UUCP (Sandra J Loosemore)
Newsgroups: comp.lang.lisp
Subject: Re: Common Lisp Problems with Hash-table in Macros
Message-ID: <739@wasatch.UUCP>
Date: 9 Dec 88 16:56:51 GMT
References: <698@crin.crin.fr>
Sender: news@wasatch.UUCP
Reply-To: sandra%defun.utah.edu.UUCP@wasatch.UUCP (Sandra J Loosemore)
Organization: PASS Research Group
Lines: 39

In article <698@crin.crin.fr> stephan@crin.crin.fr (Stephan BRUNESSAUX) writes:
>
>Is there anybody out there who can explain me
>what is wrong with this example which correctly
>runs in both interpreted and compiled mode on
>Symbolics 3620 (Genera 7.2)
>and correctly ONLY in interpreted mode on TI Explorer II
>and on VAX running KCL (June 3, 1987) but not in compiled
>mode !?... 
>
>   |   >(defmacro test (a b)  
>   |      (let ((table (make-hash-table :size 1)))
>   |        (setf (gethash a table) b)
>   |        `(defun aux () 
>   |           (maphash #'(lambda (key val) 
>   |                        (format t "key: ~a - val: ~a~%" key val)) 
>   |                    ',table))))
>   |   TEST
>   |   
>   

As it happens, this exact problem is under discussion on the
cl-compiler mailing list.  The problem is that your macro expansion
includes a quoted hash table, and not all Common Lisp implementations
currently know how to compile constant hash tables.  There is also a
fundamental problem involved: since the compiler is allowed to
"collapse" or coalesce EQUAL substructures, there is a possibility
that an EQ or EQL hash table may compile into one with fewer entries!
Another complication is that (as I understand it) KCL's compiler works
by PRINTing constant data structures to a file, and CLtL does not
require hash tables to print in such a way that they can be read in
again.  

In short, you'll have to treat it as "an error" to compile quoted hash
tables.  The ANSI Common Lisp standard may end up specifying some
other, more useful behavior, but that won't be of much use to you in
the near term. 

-Sandra Loosemore (sandra@cs.utah.edu)