[racket] Continuations & side effects
Hello, Racket users!
Here is an example I difficultly understand:
#lang scheme
(define saved '*dummy-value*)
(define next-year (+ 1 (call/cc (lambda (g) (set! saved g) 1997))))
(saved 2012)
In some other interpreters, it is OK. But Racket's answer is:
define-values: cannot re-define a constant: next-year
I can understand that variables cannot be set by means of
continuations in Racket. But if I change it into:
#lang scheme
(define saved '*dummy-value*)
(define next-year 1000)
(set! next-year (+ 1 (call/cc (lambda (g) (set! saved g) 1997))))
(saved 2012)
there is no error, and "next-year" evaluates to 2013, as expected.
Why such a difference, please?
Yours faithfully,
J.-M. H.
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.