Path: utzoo!attcan!uunet!mcvax!inria!crin!stephan From: stephan@crin.crin.fr (Stephan BRUNESSAUX) Newsgroups: comp.lang.lisp Subject: Re: Common Lisp Problems with Hash-table in Macros Message-ID: <701@crin.crin.fr> Date: 13 Dec 88 19:15:43 GMT Reply-To: stephan@crin.crin.fr (Stephan BRUNESSAUX) Organization: C.R.I.N Lines: 57 In article <393@aipna.ed.ac.uk> you write: >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)))) > >The problem is that you're trying to compile some code that contains >aquoted hash table. So, the compiler has to put a representation of >that hash table into the ".o" file. In KCL, the hash table just gets >PRINTed and so looks like this: > > # > >When LOAD tries to read this, it calls READ which sees the # and calls >the reader for the # dispatching character macro. It then sees the < >and signals an error. > >I don't know what happens on the Explorer. My first question is : why the compiler does not DUMP the hash table ? The above example correctly runs if you supersede the hash table by a vector (with some changes to display the contents). On Symbolics, the hash table is DUMPed; so, you can read or modify the hash table after loading the compiled file. On KCL, it is impossible since it is a PRINTed representation which is compiled. On Explorer, the hash table seems to be dumped but no longer works since you cannot add or remove any entries. My second question is : Am I right to write that kind of macro ? My third question is : As far as I developped on Symbolics (in Common Lisp package) a big software using that kind of macros, is it normal to encounter such problems on others Common Lisps ? Thanks for all suggestions. STEPHAN. -- Stephan Brunessaux CRIN-INRIA Lorraine BP 239 - 54506 VANDOEUVRE CEDEX - FRANCE E-MAIL: stephan@crin.crin.fr