Subject: Re: Ask a question about internal function
From: (Rob Warnock)
Date: Thu, 22 May 2008 02:52:11 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Blackguester  <> wrote:
| Actually, I migrate some code from scheme with just replace the
| define with defun, and just wonder why this can't work in lisp.

Because despite their strong surface similarities, Scheme and
Common Lisp really are *different* languages -- not just a few
keywords or function names different, but structurally different
and with different semantics [at least in places].

Also, the "internal DEFINE" in Scheme -- that is, a DEFINE inside
a <body> [as defined in the spec] -- is IMHO a very confusing
construct for newbies, since it's *really* not a "DEFINE" at all
but an implicit alias for a LETREC, see:

Now it happens to be the case that Common Lisp has no *exact*
equivalent for the full generality of LETREC [that is, binding
both recursive functions & local values intermingled within the
same binding form], though for bindings of functions the Common
Lisp LABELS form offers the same ability as LETREC to define
mutually-recursive functions, and the Common Lisp LET* form
offers the ability to perform variable bindings for which the
value-initializing expression can refer to earlier variable
bindings within the same LET*. So you can get the equivalent
semantics, though translating a pathologically-convoluted LETREC
might need several LABELS and/or LET* forms to get the same
resultant semantics.[1]


[1] Hmmm... You *might* always be able to do it with only one
    SYMBOL-MACROLET form containing only one LABELS form, where
    the former defines some of the "variables" to be function
    calls of dummy functions in the latter returning quasi-contant
    values...  But I haven't verified that to be sure.

Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607