Path: utzoo!attcan!uunet!yale!Krulwich-Bruce From: Krulwich-Bruce@cs.yale.edu (Bruce Krulwich) Newsgroups: comp.lang.lisp Subject: Re: Common Lisp Problems with Hash-table in Macros Message-ID: <45602@yale-celray.yale.UUCP> Date: 14 Dec 88 01:39:45 GMT References: <698@crin.crin.fr> <290@nvuxh.UUCP> Sender: root@yale.UUCP Reply-To: Krulwich-Bruce@cs.yale.edu (Bruce Krulwich) Organization: Computer Science, Yale University, New Haven, CT 06520-2158 Lines: 35 In-reply-to: hall@nvuxh.UUCP (Michael R Hall) In article <290@nvuxh.UUCP>, hall@nvuxh (Michael R Hall) writes: >The example works fine, both interpreted and compiled, in Sun >(Lucid) Common Lisp version 3.4. The problem, therefore, is KCL. >Many Common Lisp implementations have buggy lexical closures, >especially compiled. I don't know why, since they're not all that >hard to implement. I suspect the KCL compiler cannot generate proper >lexical closure code, even though the lexical closure in question >references no variables outside its body. The first example >uses #'print, which works fine in KCL; the second example uses >#'(lambda (key val) [body omitted]) and the KCL compiler barfs. I >suggest defining a function like this > (defun foo (key val) [body omitted]) >and then referencing it as #'foo. >This, of course, should not make a difference, but it may make all >the difference to a buggy version of Common Lisp. I believe that the problem has nothing to do with references out of the closure, or really anything to do with the closure handling itself. I think that the problem lies in creating a hash table (or possibly another complex data structure) at COMPILE-TIME and loading it in with the compiled code. This is slightly related to a discussion a while ago about the environment in which code is compiled, and the effect of compilation on the environment. In this case you creating the hash table in the environment in which macros are expanded, and then saving it into a file, referencing it from code compiled in a seperate environment in the process. It is much more straightforward to move the creation into the expanded macro, thus creating the table at load time (as I showed in my previous post). Does anyone remember the outcome of the previous discussion on compiler environments?? Is the example that started this discussion correct within CL?? Bruce Krulwich