Hey!
When you are not referencing x before defining y everything works as you
want. There is no, so to say, temporal dependency on how the things are
bound. When you introduce (display x) before actually defining y you
force letrec* to bind x to the unspecified value, because display has
side-effects and you don't move around side-effecting code.
If you do (display "heippa!") instead it works as you want.
I believe racket (which does the same optimization) has the same behaviour.
-- Linus Björnstam
Den 2023-09-24 kl. 09:09, skrev Dr. Arne Babenhauserheide:
Hi,
while writing a comment to SRFI-245 I think I found an inconsistency in
the Implementation in Guile.
This works:
(define (using-later-variable)
(define x y)
(define y #t)
x)
(using-later-variable)
;; => #t
This still works:
(define (using-later-variable)
(define x y)
(newline)
(define y #t)
x)
(using-later-variable)
;; => (newline output)
;; => #t
This fails:
(define (using-later-variable)
(define x y)
(display x)
(newline)
(define y #t)
x)
(using-later-variable)
;; => #<unspecified>
Best wishes,
Arne