> jredford_at_lehman.com writes
>
> I am working on implementing a scheme interpreter for various reasons,
> and while working on the semantics of 'do' I was checking to see what
> other interpretations were. Given the following code:
>
> (do ((x 5 (+ x 1)))
> ((> x 10) x)
> (if (= x 7) (define uu 88))
> (if (= x 8) (define uu 33))
> (if (= x 9) (display uu) (newline)))
>
> Stk seems to return 89, whcih makes no sense to me.
Do is a macro in STk and its expansion is:
(letrec
((|G1| (lambda (x)
(if (> x 10)
(begin x)
(begin
(if (= x 7) (define uu 88))
(if (= x 8) (define uu 33))
(if (= x 9) (display uu) (newline))
(|G1| (+ x 1)))))))
(|G1| 5))
The problem lies in in the letxxx forms: To speed up interpretation, code is
changed when executed the first time. This is this program transformation lead
to problem in this case (binding to uu is taken for the one for x and 88 is
incremented to give 89 ; this explains the weird result.
Correcting this problem is not too hard, but it will makes internal define
more inefficient.
However, R4S states that internal defones shoulb be at the beginning of a let
construction, so previous is not a correct R4RS construction.
-- Erick
Received on Thu Mar 09 1995 - 15:48:07 CET
This archive was generated by hypermail 2.3.0
: Mon Jul 21 2014 - 19:38:59 CEST