Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!decwrl!shelby!neon!neon!gumby From: gumby@Cygnus.COM (David Vinayak Wallace) Newsgroups: comp.lang.lisp Subject: flet, a question of style? Message-ID: Date: 4 Aug 90 20:18:10 GMT References: <1990Aug4.001913.22597@Neon.Stanford.EDU> Sender: news@Neon.Stanford.EDU (USENET News System) Organization: Cygnus Support Lines: 27 In-Reply-To: rit@killdeer.Stanford.EDU's message of Sat, 4 Aug 90 00:19:13 GMT Date: Sat, 4 Aug 90 00:19:13 GMT From: rit@killdeer.Stanford.EDU (Jean-Francois Rit) The way I see it, the advantages of flet over an external defun are: - cleanliness of code: the local function is defined right where it is only needed and that is made clear to the reader. Unfortunately in a large system you then end up with a rats-nest of nested functions. The package system (poorly) addresses this issue. - Use of lexical context: when the flet is defined in the right place, a lot of local variables need not be passed to the function. Not only that but it allows you to side-effect variables in its lexical environment, which is really handy. - It is more expensive. There's no reason why it need be. In the case where the lexical function is not passed down the stack it can be open-coded. And if you know that the function will be passed down but never up, then it can share the environment of its enclosing function. Unfortunately you can't do this on register-window machines like the SPARC. On those machines downward funarg can be somewhat expensive.