Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!accuvax.nwu.edu!Krulwich From: Krulwich@eecs.nwu.edu (Bruce Krulwich) Newsgroups: comp.lang.lisp Subject: Re: Simple question RE nested DEFUNs Message-ID: <979@accuvax.nwu.edu> Date: 31 Jul 89 19:09:41 GMT References: <89Jul31.114325edt.11243@ephemeral.ai.toronto.edu> Sender: news@accuvax.nwu.edu Reply-To: Krulwich@eecs.nwu.edu (Bruce Krulwich) Organization: Institute for the Learning Sciences, Northwestern University, Evanston, IL 60201 Lines: 21 In-reply-to: bradb@ai.utoronto.ca In article <89Jul31.114325edt.11243@ephemeral.ai.toronto.edu>, bradb@ai writes: > I come from a Scheme background, where I'm used to defining helping > functions within the body of the function being helped, as in ... > Now, when I do this in CommonLisp, I notice that the inner DEFUN > (the one for bar in my example) is actually being re-defined on > every invocation of foo. Eek, this is not what I wanted! I wanted > the function to be defined exactly once, before foo is ever called, > but available only within the scope of the definition of foo. The way to do this is to use LABELS, which is completely analogous to LETREC in Scheme. The semantics of internal DEFINE's in Scheme has always seemed screwball to me, and this seems to be a case where CL is more consistant than Scheme, in that ALL forms that introduce variables into a binding layer involve nesting the body over which the variables are scoped. Additionally, the semantics of DEFUN are clear: it always defines a global function. Bruce