From: Rob Warnock on
Kazimir Majorinc <email(a)false.false> wrote:
+---------------
| [rpw3 wrote:]
| > To each his own. I prefer bare LET*, since you can have multiple
| > distinct intertwined names without added contortions ...
| > (let* ((a (init-a))
| > (b (init-b))
| > (c (init-c))
| > (a (foo a b c))
| > (b (bar b c a))
| > (c (baz c a b))
| > (a (gorp a b c))
| > (b (quux b c a))
| > (c (frob c a b)))
| > ...)
| > How would you do that with CHAIN? Introduce more magic characters?
| > [Maybe use *, **, and *** ?!? ;-} ]
|
| OK; I see the point here. Look at this:
|
| (let (a b c ...)
| (setf a (init-a))
| (setf b (init-b))
| (setf c (init-c))
| (setf a (foo a b c))
| ...))
|
| Would you say that it is semantically slightly more adequate,
| but syntactically less convenient to the purpose?
+---------------

Actually, I would say that it's semantically *less* adequate! Consider:

> (let* ((a 'first-a)
(a1 (lambda () a))
(a 'second-a)
(a2 (lambda () a))
(a 'third-a)
(a3 (lambda () a))
(a 'last-a)
(a4 (lambda () a)))
(mapcar #'funcall (list a1 a2 a3 a4)))

(FIRST-A SECOND-A THIRD-A LAST-A)
>

Note that each A above is a *separate* binding, with indefinite extent,
captured individually by each closure. Whereas your suggestion would
change the semantics entirely:

> (let (a a1 a2 a3 a4)
(setf a 'first-a)
(setf a1 (lambda () a))
(setf a 'second-a)
(setf a2 (lambda () a))
(setf a 'third-a)
(setf a3 (lambda () a))
(setf a 'last-a)
(setf a4 (lambda () a))
(mapcar #'funcall (list a1 a2 a3 a4)))

(LAST-A LAST-A LAST-A LAST-A)
>


-Rob

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

From: Pascal Costanza on
On 31/03/2010 18:17, Kazimir Majorinc wrote:
> On 31.3.2010 10:40, Pascal Costanza wrote:
>
>>
>> Coincidentally, in Java this is not allowed. ;)
>
> It is the step further in hygiene. Maybe it was Steele's influence.

I don't think it would help wrt macro hygiene issues.


Pascal

--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Pascal J. Bourguignon on
Pascal Costanza <pc(a)p-cos.net> writes:

> On 31/03/2010 03:08, Kazimir Majorinc wrote:
>> Is anyone aware of "natural" occurences of the s-expressions similar to
>>
>> (let((x ...))
>> ...
>> (let((x ...))
>> ...
>> ...))
>>
>> in any Lisp dialect?
>
> Coincidentally, in Java this is not allowed. ;)

You mean, like in:

(let* ((x (f 0))
(x (g x))
(x (h x)))
...)

I don't understand what is so special about

(let ((x ...))
...
(let ((x ...))
...))

and indeed, I happen to write it, more than once.

For example, where you would use setf, you can often transform the setf
with the following forms in an embedded let like this. Obviously, with
the same variable name, there would be no point in renaming it.

If Java doesn't allow what C/C++ allow, shame on it!

{
int x=...;
...
{
int x=...;
...
}}


--
__Pascal Bourguignon__
http://www.informatimago.com