public inbox for
 help / color / mirror / Atom feed
From: Per Bothner <>
To: Mark Raynsford <>,
Subject: Re: Difference in define behaviour between kawa.jar and embedded Scheme example
Date: Thu, 23 Nov 2017 02:26:00 -0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On 11/22/2017 11:33 PM, Mark Raynsford wrote:
> 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-line
(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.
   $ kawa demo0.scm
   $ 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

  reply	other threads:[~2017-11-23  2:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22 22:33 Mark Raynsford
2017-11-23  2:26 ` Per Bothner [this message]
2017-11-23 10:52   ` Mark Raynsford
2017-11-23 12:51     ` Per Bothner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).