[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
letrec and set!
(letrec ((x (begin (set! y 1)
y ))
(y 3) )
x ) ---> 1
But if letrec is operationally explained by a let with inner
assignments, the way it is actually in r4rs, what is the reason to
forbid writing to a mutually defined variable, nor it is necessary to
require a "smart" compiler.
> (letrec ((x (begin (assign-to-cell! y 1) (refer-to-cell y)))
> (y (make-cell 3)))
> x)
Incidently I see the box model (or value cell) without explicit
initialization so I see the program fragment more like:
(let ((x (create-box))
(y (create-box)) )
; `let' to keep undeterminacy
(let ((void1 (box-set! x (begin (box-set! y 1) (box-ref y))))
(void2 (box-set! y 3)) )
(box-ref x) ) )
Christian.