Subject: Re: Dr. Scheme "local"?
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 2000/06/19
Newsgroups: comp.lang.scheme
Message-ID: <8iju42$88ld$1@fido.engr.sgi.com>
Boris Schaefer  <boris@uncommon-sense.net> wrote:
+---------------
| What about:
|   ((lambda ()
|      (begin
|        (define x 3)
|        (define y 2)
|        (define z (* x y))
|        z)))
| 
| As R5RS says: 
|   The <expression>s are evaluated sequentially from left to right, and
|   the value(s) of the last <expression> is(are) returned.  This
|   expression type is used to sequence side effects such as input and
|   output.
| 
| So, I would think the above is equivalent to (local ...), as the begin
| guarantees that the internal defines are evaluated sequentially.  Or
| am I still missing something?
+---------------

Yes, you're still missing something, I'm afraid. Internal definitions
are not themselves "expressions", they're "internal definitions" --
and as such are *exactly* equivalent to a *single* "letrec" expression.
[See R5RS Section 5.2.2 "Internal definitions".] That is, your example
above is *defined* to mean this:

    ((lambda ()
       (begin			; now redundant
         (letrec ((x 3)
		  (y 2)
		  (z (* x y)))
	   z)))

The "begin" contains only one expression (the "letrec"), and thus there
is no "left to right" sequentiality involved at all.

Oh, and the "letrec" bindings violate the rules [R5RS 4.2.2 & 5.2.2]
requiring that "it must be possible to evaluate each <init> without
assigning or referring to the value of any <variable>"...


-Rob

-----
Rob Warnock, 41L-955		rpw3@sgi.com
Applied Networking		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043