Open zv opened 5 years ago
My question relates to the exercise 4.19.
SICP says in a footnote:
The MIT implementors of Scheme support Alyssa on the following grounds: Eva is in principle correct -- the definitions should be regarded as simultaneous. But it seems difficult to implement a general, efficient mechanism that does what Eva requires. In the absence of such a mechanism, it is better to generate an error in the difficult cases of simultaneous definitions (Alyssa's notion) than to produce an incorrect answer (as Ben would have it).
The answer states:
Eva's view can be easily supported by swapping the order within the 'let' quasiquote of 'set!' and '@,body'
Which one is correct? Is it difficult or easy?
I'm particularly wondering whether the answer is correct because Guile and Chez obviously don't find the implementation easy.
GNU Guile 3.0.8
Copyright (C) 1995-2021 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> (let ((a 1))
(define (f x)
(define b (+ a x))
(define a 5)
(+ a b))
(f 10))
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure +: Wrong type argument in position 1: #<unspecified>
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
Chez Scheme Version 9.5.8
Copyright 1984-2022 Cisco Systems, Inc.
> (let ((a 1))
(define (f x)
(define b (+ a x))
(define a 5)
(+ a b))
(f 10))
Exception: attempt to reference undefined variable a
Type (debug) to enter the debugger.
All comments on this Github issue (aside from this one) will be shown on my blog as Github-style markdown formatted comments on whichever post shares this issue's title.