[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DEFUN inside LET



    Date: Tue, 28 Jan 1986  23:12 EST
    From: "Scott E. Fahlman" <Fahlman@edu.cmu.cs.c>

    I'm not sure if there's actually a firm consensus on this, but in my
    opinion Defun inside Let should always work.  It's an idiom I use a lot,
    and if some alleged Common Lisp didn't supply this, I'd either complain
    or fix it myself.

Another issue is what DEFUN inside LET should do.  My understanding of Common
Lisp is that

  (let ((a 1)) (defun f () a) ...)

is supposed to be equivalent (modulo implicit blocks, &c) to

  (let ((a 1)) (setf (symbol-function 'f) #'(lambda () a)) ...)

but that in Scheme it is equivalent to

  (let ((a 1)) (labels ((f () a)) ...))

In other words, does an internal DEFUN define a local or a global function?
My opinion now is that I would rather have it define a local function (a la
Scheme), because I think that looks better than a LABELS, because I use local
functions a lot, and because, to me, it seems more natural.  But if I used
global functions defined inside environments a lot, I could well change my
mind since the SETF is clearly worse than LABELS (and hence more in need of a
sweetened syntax).  At the moment, though, I'm not sure what a global DEFUN
inside a LET is supposed to express (i.e., what is it good for?).

-- Jeff