From: "Dr. Arne Babenhauserheide" <arne_bab@web.de>
To: "Linus Björnstam" <linus.bjornstam@fastmail.se>
Cc: guile-devel@gnu.org
Subject: Re: Inconsistency with expressions between definitions
Date: Sun, 24 Sep 2023 18:02:45 +0200 [thread overview]
Message-ID: <87fs33v9ft.fsf@web.de> (raw)
In-Reply-To: <fee8a57f-ab13-6399-f407-3219f9c35ba4@fastmail.se>
[-- Attachment #1: Type: text/plain, Size: 1292 bytes --]
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]
next prev parent reply other threads:[~2023-09-24 16:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-24 7:09 Inconsistency with expressions between definitions Dr. Arne Babenhauserheide
2023-09-24 11:58 ` Linus Björnstam
2023-09-24 16:02 ` Dr. Arne Babenhauserheide [this message]
2023-09-25 12:48 ` Linus Björnstam
2023-09-25 13:53 ` Dr. Arne Babenhauserheide
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fs33v9ft.fsf@web.de \
--to=arne_bab@web.de \
--cc=guile-devel@gnu.org \
--cc=linus.bjornstam@fastmail.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).