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: Dr. Arne Babenhauserheide
Subject: Re: Inconsistency with expressions between definitions
Date: Sun, 24 Sep 2023 18:02:45 +0200
User-agent: mu4e 1.10.7; emacs 29.0.92

Hi,

Linus Björnstam <linus.bjornstam@fastmail.se> writes:

> 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.

This is a technical explanation. It answers "how does this happen?"
(thank you for that!), but not "why is this the correct behavior?".

The core problem I see: if you inject some logging code between the
defines, the behavior changes.

I would expect that referencing a variable that can’t yet be used in an
intermediate expression (between defines) would not cause a (potentially
subtle) behavior change, but would throw an error: variable used in
expression that depends on later define.

Racket does not support defines using later defines at all:

$ racket
> (define (using-later-variable)
>      (define x y)
>      (define y #t)
>      x)
> (using-later-variable)
y: undefined;
 cannot use before initialization
 [,bt for context]

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de

Attachment: signature.asc
Description: PGP signature


reply via email to

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