New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
letrec* incorrectly reorders statements #659
Comments
Marc said on gitter: Concerning the implementation of |
Fix by SamuelYvon; fixes issue #659.
Fixed by 47f2eb7 |
Sometimes we make mistakes. Reopening. |
NB: the fix was immediately reverted in the next commit d1a6c6b because it broke some regression tests... that I believe might need be updated. |
$ ./gsc/gsc
Gambit v4.9.4-211-g97e4bff5
> (define (displayln . a) (for-each display a) (newline))
> (define (reordered)
(letrec* ((x (begin (displayln 100) 42))
(_200 (displayln 200))
(_300 (displayln 300 (list x)))
(_400 (displayln 400))
(y (begin (displayln 500) 23)))
(displayln 600 (list y))))
> (reordered)
100
200
300(42)
400
500
600(23) Isn't this the desired behaviour? |
Yes, this is the desired behaviour. As of 4.9.4-210-g420f1e5e, it works in the interpreted case, and fails in the compiled case with
|
Do you have a link to the spec where conditions about reordering can be found? |
I suppose that would be r7rs section 4.2.2 "Binding constructs": https://standards.scheme.org/corrected-r7rs/r7rs-Z-H-6.html#TAG:__tex2page_sec_4.2.2 |
I see. I'm still trying to wrap my head around the exact semantics. Can you confirm that this following example would be illegal:
|
Why would that be illegal? You bind |
It was too early in the morning, my example is miswritten, I was trying to construct something that refers to:
from the R7RS spec. Flipping the Something like this "breaks" in chicken scheme: (letrec* ((x y)
(y (lambda (z) (+ z 5))))
(print x)) since |
Agreed. (Except I make no comment on the implementation, that I didn't look at properly). |
Important fix affecting Gerbil, wrt compilation of letrec*. See gambit/gambit#659
Pin gambit to 24201248effa23d5017be4992b5b9879e4cd3a4c Important fix affecting Gerbil, wrt compilation of letrec*. See gambit/gambit#659
R7RS says that
letrec*
should not reorder the side-effects, that will happen from left-to-right, but this function, when compiled (as opposed to interpreted, which works correctly), reorders line 300 below line 500, which is incorrect. Presumably, it detects that 400 and 500 do not "depend" on x (or anything else defined in theletrec*
), whereas 300 does.The text was updated successfully, but these errors were encountered: