Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Can LET* reuse variables?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andrew Philpot  
View profile  
 More options Oct 5 1995, 3:00 am
Newsgroups: comp.lang.lisp
From: phil...@sungod.isi.edu (Andrew Philpot)
Date: 1995/10/05
Subject: Can LET* reuse variables?
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pierpaolo Bernardi  
View profile  
 More options Oct 6 1995, 3:00 am
Newsgroups: comp.lang.lisp
From: berna...@cli.di.unipi.it (Pierpaolo Bernardi)
Date: 1995/10/06
Subject: Re: Can LET* reuse variables?
Andrew Philpot (phil...@sungod.isi.edu) wrote:

: Is code like (LET* ((A 1)
:                     (A (+ A 2)))
:               ...)
: legal CL?

Yes. It is definitely legal.

: 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)))) ...)

I hope that you didn't paid any money for this one!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Oct 7 1995, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1995/10/07
Subject: Re: Can LET* reuse variables?
[Andrew Philpot]

|   Is code like (LET* ((A 1)
|                       (A (+ A 2)))
|                 ...)
|   legal CL?

[Pierpaolo Bernardi]

|   Yes. It is definitely legal.

hmmm.  what is the precise semantics of this construct in the presence of
declarations of A?  e.g. will a (declare (special a)) cause one of A's to
be special and one to have lexical scope, or will both be special?

I can't find anything in ANSI CL which would support the "definitely", but
it appears to be legal, while it appears not to be legal in `let'.  I don't
see why there should be a difference between the two, or where it is
specified that there is such a difference.

#<Erik 3022029208>
--
"He [O. J. Simpson] is going to kill me, and he is going to get away with it."
                                           -- Nicole Brown Simpson (1959-1994)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »