Per Bothner
2017-11-23 02:26:20 UTC
In other words, the redefinition of + on the second line is affecting
the existing definition of six0 so that the applications of six0 and
six1 are both returning 9. What's going on here?
The behavior of demo0.scm depends on whether it is evaluated line-by-linethe existing definition of six0 so that the applications of six0 and
six1 are both returning 9. What's going on here?
(as in REPL) or as a "module" (or "library" in R7RS-speak). The latter
is the default, but you can force teh former using the -f options.
Compare:
$ kawa demo0.scm
vs:
$ kawa -d demo0.scm
Either implicitly imports (kawa base). In general it is invalid to
explicitly define bindings that conflict with imported bindings.
We are somewhat more lenient with (kawa base), for compatibility
with tradition, but it is still a bad idea.
Instead you can do something like:
(import (except (kawa base) +))
(import (only (kawa base) (+ orig-+)))
(define (six0 x) (orig-+ 3 3))
(define (+ x y) (* x y))
(define (six1 x) (+ 3 3))
(format #t "[~w ~w]~%~!" (six0 0) (six1 0))
--
--Per Bothner
***@bothner.com http://per.bothner.com/
--Per Bothner
***@bothner.com http://per.bothner.com/