Subject: Re: how to define a local function
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 12 Apr 2007 22:02:53 -0500
Newsgroups: comp.lang.lisp
Message-ID: <8IGdnTJkD45Ab4PbnZ2dnUVZ_jednZ2d@speakeasy.net>
Barry Margolin  <barmar@alum.mit.edu> wrote:
+---------------
| rpw3@rpw3.org (Rob Warnock) wrote:
| > Right. Actually, Scheme gets it right for a Lisp1, with LET/LET*
| > and LETREC instead of CL's LET/LET*/FLET and LABELS. But LETREC
| > and LABELS have different syntaxes and semantics. LETREC binds
| > arbitrary *values*, not functions [though in a Lisp1 a "value"
| > which is an evaluated LAMBDA expression "is" a function], while
| > LABELS binds *only* functions, like FLET.
| 
| But the difference between LET and LETREC is only significant for the 
| function values.  But I suppose you could get cute and have things like:
| 
| (letrec ((fun1 (lambda ...))
|          (list-of-funs (list (lambda ...)
|                              (lambda ...))))
|   ...)
| 
| fun1 can use ((car list-of-funs) ...).
+---------------

Exactly. That doesn't work for any variable-binding construct
built into CL.[1]


-Rob

[1] Though as I noted, one could write a LETREC macro
    in CL that does it the same way Scheme does. The URL
    <http://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-10.html>
    has a reference LETREC macro (in Scheme) that could be
    translated to CL fairly easily, I suspect.

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607