Path: utzoo!attcan!uunet!yale!husc6!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.lang.lisp Subject: Re: nested function definitions Message-ID: <22427@think.UUCP> Date: 22 Jun 88 03:50:10 GMT References: <5862@spool.cs.wisc.edu> <5568@utah-cs.UUCP> <3257@ubc-cs.UUCP> Sender: usenet@think.UUCP Reply-To: barmar@kulla.think.com.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge, MA Lines: 34 In article <3257@ubc-cs.UUCP> manis@faculty.cs.ubc.ca (Vincent Manis) writes: >I think it's a mistake to define an internal definition to change the >*global* value of the function cell: this is almost always not what >one would expect, given lexical binding. Either don't provide it at >all (as CL doesn't) or give it the same semantics as in Scheme. Why is it any wronger for DEFUN to change the global value than it is for SETQ? The way I think of it, DEFUN is to FLET/LABELS as SETQ is to LET. This does bring up a good question for the X3J13 compiler subcommittee to consider. What does: (defun foo (x) (flet ((internal (y) (+ x y))) (defun internal (y) (* x y)) (internal 3))) do? If my analogy is completely correct, this shouldn't have any effect on INTERNAL's global function cell. From what I remember at the X3J13 meeting, I think my analogy is incorrect. I think the analogy that the compiler subcommittee is using is DEFUN is to FLET as (SETF SYMBOL-VALUE) is to FLET, i.e. (DEFUN name ...) macroexpands into (SETF (SYMBOL-FUNCTION 'name) #'(LAMBDA ...)) plus some unspecified implementation-specific stuff. Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar