Is code like (LET* ((A 1)
(A (+ A 2)))
...)
legal CL?
It sure seems like it should be to me, whether I interpret it via
CLtL2 or the ANSI spec, or consider representing it in terms of nested
LETs (how I usually think about it):
(LET ((A 1))
(LET ((A (+ A 2)))
...))
This might be a good way to write a macro transformer for the LET*
special form, and in fact it's close to what LUCID does, (LUCID goes
on to replace the LETs with their equivalent LAMBDAs:
((LAMBDA (A)
((LAMBDA (A) ...) (+ A 2)))
1)
However, one implementation (which will go nameless for now) includes
a macro-function definition of LET* which transforms it into something
like the following:
((LAMBDA (&optional (A 1) (A (+ A 2)))) ...)
Note that in the more general case, this is a clever trick: The syntax
allows for defaulting values and assigning sequentially. It avoids
the problem of deeply nested expressions (in case that's a compiler or
run-time consideration).
However, for this special case, it fails miserably, since you can't
reuse the same variable name in a lambda list.
Now I don't make a habit of reusing variable names in LET* in this
way, but I have encountered code which does, and I certainly could
imagine such code being automatically generated by a macro or other
code processing program.
Is such code in error, or is the implementation lacking?
--
---------------------------------------------------------------
Andrew Philpot USC Information Sciences Institute
phil...@isi.edu 4676 Admiralty Way
(310) 822-1511 ext 201 Marina del Rey, CA 90292-6695