Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!news.bluesky.net!news.sprintlink.net!howland.reston.ans.net!xlink.net!rz.uni-karlsruhe.de!news.uni-ulm.de!news.belwue.de!news.belwue.de!delos.stgt.sub.org!saruman.lb.bawue.de!shendi
From: shendi@saruman.lb.bawue.de (Alexander Shendi)
Subject: Re: Definition of "let*"?
Message-ID: <1995Jun13.225758.13591@saruman.lb.bawue.de>
Organization: private Linux site, Asperg, Germany 
Date: Tue, 13 Jun 1995 22:57:58 GMT
References: <3rknc6$rli@verdandi.cs.cornell.edu>
X-Newsreader: TIN [version 1.2 PL2]
Lines: 40

Hi all,

Brent Knight (knight@cs.cornell.edu) wrote:

: Hello,

: Is the following legal scheme, or is it illegal due 
: to the repeated occurrence of "x" as a left-hand side?

: (let* ( (x 1)
:        (x (+ 1 x)) )
:      x)

: I would like this to return the number 2.

: a)  This seems like a useful, well-defined thing to do.
: b)  It appears to be outlawed by the R^4RS (!)
: c)  Some common implementations (scm, scheme48) do not treat it as an error
:     and seem to do The Right Thing(tm).
: d)  Another implementation, (stk-2.1.7) reports it as an error.

This should be legal scheme as chapter 7.3 ("Derived expression types")
of R4RS says this is equivalent to:

(let ((x 1))
  (let ((x (+ 1 x)))
    x))

which in turn is equivalent to:

((lambda (x)
   ((lambda (x) x) 
       (+ 1 x)))
   1)

which should indeed yield 2.
 

-- 
Alexander Shendi                              shendi@saruman.lb.bawue.de
