Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!shelby!csli!johnson From: johnson@csli.STANFORD.EDU (Mark Johnson) Newsgroups: comp.lang.lisp Subject: Re: Self-referencing Closures Message-ID: <7931@csli.STANFORD.EDU> Date: 7 Mar 89 16:46:59 GMT References: <6859@phoenix.Princeton.EDU> <52880@yale-celray.yale.UUCP> Sender: johnson@csli.Stanford.EDU (Mark Johnson) Reply-To: johnson@csli.stanford.edu (Mark Johnson) Organization: Center for the Study of Language and Information, Stanford U. Lines: 20 Bruce Krulwich is quite correct - the LABELS form is what you need to make these self-referencing closures. His example contains a minor bug, however: he forgot to use #' in front of the final -self- form. The corrected version is: (defun make-closure () (labels ((self () (print 'hello))) #'self)) Too much Scheme! Someone else just sent a message on the net asking why CommonLisp uses different name spaces for variable and function definitions. Personally, I think that this is one of the worst features of CommonLisp. It makes my programs look like fields of #' symbols and funcalls. It is also one of the hardest things for students to learn - they get continually confused between the use of LIST as a function and a variable. (I know it's bad programming style, but people do do it). Mark Johnson