Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!godot.cc.duq.edu!newsfeed.pitt.edu!gatech!swrinde!howland.reston.ans.net!newsfeed.internetmci.com!in2.uu.net!bostech!halchin
From: halchin@bostech.com (Willliam Halchin)
Subject: Re: Lambda  (Implementing R4RS)
Message-ID: <1996Apr19.175347.858@bostech.com>
Organization: Boston Technology, Wakefield, MA
References: <317531E0.FF6@td2cad.intel.com> <4l5ska$f0s@news.xmission.com> <4l6oep$qlc@camelot.ccs.neu.edu>
Date: Fri, 19 Apr 96 17:53:47 GMT
Lines: 57

In article <4l6oep$qlc@camelot.ccs.neu.edu> will@ccs.neu.edu (William D Clinger) writes:
>In article <4l5ska$f0s@news.xmission.com>
>callahan@xmission.com (Michael Callahan) writes:
>>Ram Firestone (ram@td2cad.intel.com) wrote:
>>: (let ( (v (make-vector 5)) )
>>:    (do ( (i 0 (+ i 1)) )
>>:        ( (= i 5) 
>>:          ((vector-ref v 2)) )
>>:       (vector-set! v i (lambda () i))
>>:    )
>>: )
>>
>>It's not that good of a question.  It just depends on wheter or not
>>do is expanded into a tail-recursive call with the iteration variables
>>passed as parameters or explicitly set!.  If they are set!, then the
>>answer would be 5, otherwise it would be 2.  I had to look up in the
>>R4RS which was the case, it turns out that the same bindings are
>>reused, so 5 would be the result.
>
>Your explanation is correct, but you misread the R4RS.  The
>correct result is 2, not 5.
>
>The relevant paragraph of R4RS section 4.2.4 (emphasis added):
>
>    Each iteration begins by evaluating <test>; if the result
>    is false (see section 6.1), then the <command> expressions
>    are evaluated in order for effect, the <step> expressions
>    are evaluated in some unspecified order, the <variables>
>    are bound to fresh locations, the results of the <step>s
>        ------------------------
>    are stored in the bindings of the <variable>s, and the
>    next iteration begins.
>
>R4RS section 7.3 gives an equivalent but more formal explanation
>by way of a syntactic transformation into procedure calls.  There
>are no uses of SET! in the transformed DO.
>
>William D Clinger


Two related questions:

1) What is R4RS??

2) Where are the "vector" functions, e.g. vector-ref, vector-set!, defined?
    I.e. are they in a Scheme library?? I am looking at Scheme48 abstract 
    machine interpreter where these are used!

3) What is the scope of "do" "construct"??


Please send email!

Regards,`
`
Vasili N. Galchin

