Path: utzoo!attcan!uunet!cs.utexas.edu!rutgers!aramis.rutgers.edu!atanasoff.rutgers.edu!lou From: lou@atanasoff.rutgers.edu (Lou Steinberg) Newsgroups: comp.lang.lisp Subject: Re: flet, a question of style? Message-ID: Date: 7 Aug 90 13:30:34 GMT References: <1990Aug4.001913.22597@Neon.Stanford.EDU> Organization: Rutgers Univ., New Brunswick, N.J. Lines: 38 Cc: lou In article <1990Aug4.001913.22597@Neon.Stanford.EDU> rit@killdeer.Stanford.EDU (Jean-Francois Rit) writes: > What is a good use of flet? [...] The cons are: [...] One aspect that hasn't come up yet in responses (at least those I've seen) is the fact that many Lisp programming environments do not support local function definitions (i.e. defined via labels and flet) nearly as well as they do global definitions. This shows up in at least two ways. The first is that often you can't break, trace, or advise a local function. The reason is that the break/trace function can easily access a global function from the symbol that is it's name, and can then wrap that definition in break/trace code. For it to find a local definition requires it to wade through the code of the enclosing function. Not that it can't be done, but it is significantly more complex and/or less portable, and thus less often supported. (By the way, this problem is even worse for anonymous lambdas - at least the local functions have a name, if only locally.) The other way this poorer-support of local definitions shows up is in the incremental-load-compile facility that many lisps (or lisp/emacs combinations) support. It is useful to be able to modify one function, then load (and maybe compile) the modified definition without reloading/recompiling the whole program. I don't know of any lisp that allows you to do this with a local definition. In fact, if you were to go to the extreme and make all functions local except a single top level "main" function, as is normal in Pascal and such languages, then if you change anything you have to reload/recompile the whole program. (This is why even languages where local definitions are the normal case will allow non-local definitions as part of a separate-compilation facility.) -- Lou Steinberg uucp: {pretty much any major site}!rutgers!aramis.rutgers.edu!lou arpa: lou@cs.rutgers.edu