This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
(define (p) (display plus) (display (plus glob glob)) (newline))
(define (q) (set! glob 8) (set! plus -))
(p)
(q)
(p)
It prints out:
#<procedure +>10 //
ok, 5 + 5 makes 10 , then changing plus to - and glob to 8
#<procedure ->16 // here, plus is both -, and +.
In fact it should print #<procedure ->0
// Other schemes: DrScheme, ChezScheme... print 0 instead of 16
Comments:
if you change (define plus +) to (define (plus x x) (+ x x)).
The behavior of q becomes normal. It prints out:
#<procedure plus>10
#<procedure ->16
I suppose that it is due to compilation optimisation. Maybe changing
the value of
a variable whose the value was a primitive function should show a warning.
Emmanuel Castro
LIRMM
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |