Subject: Re: how to define a local function
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 13 Apr 2007 02:53:39 -0500
Newsgroups: comp.lang.lisp
Message-ID: <VJednV0iD4CeqoLbnZ2dnUVZ_hisnZ2d@speakeasy.net>
Pascal Costanza  <pc@p-cos.net> wrote:
+---------------
| Rob Warnock wrote:
| > That is, the following works in
| > Scheme, but there is no standard operator in CL that you can replace
| > the LETREC with that will work:
| >     > ((lambda (n)
| > 	 (letrec ((f (lambda (x)
| > 		       (if (<= x 1)
| > 			 1
| > 			 (* x (apply f (- x 1) '()))))))
| > 	   (apply f n '())))
| >        5)
| >     120
| >     > 
| > 
| > [Note: The funny APPLY forms, which work in both Scheme & CL,
| > are a workaround for FUNCALL per se not existing in Scheme.]
| 
| I think this example doesn't illustrate what you want to say
| (if I understand you correctly).
+---------------

No, I don't think you did understand me correctly, or at least,
not what my real point was. I carefully wrote that example so that
the whole thing *would* work in either Scheme or CL, without any
Lisp1/LispN differences in syntax, without any LET/FLET differences
in syntax, *if only* there existed some form in CL that did LETREC.

But there isn't. [...without adding a LETREC macro.]

+---------------
| In Scheme you can just say this:
...
| [Note that there is actually no need to use apply here.]
| 
| Likewise, you can say that in Common Lisp:
+---------------

Yes, but then the two expressions are *different* -- more
different that just what operator name you use for LETREC/LABELS.
One needs a LAMBDA, the other must *not* have the LAMBDA, etc.
The way I wrote it those differences were masked.


-Rob

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