guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inconsistency with expressions between definitions


From: Linus Björnstam
Subject: Re: Inconsistency with expressions between definitions
Date: Sun, 24 Sep 2023 13:58:32 +0200
User-agent: Mozilla Thunderbird

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]