From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79088 invoked by alias); 23 Nov 2017 02:26:32 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 79079 invoked by uid 89); 23 Nov 2017 02:26:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=BAYES_00,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=UD:jar, imports, H*M:9e61, tradition X-HELO: aibo.runbox.com Received: from aibo.runbox.com (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Nov 2017 02:26:30 +0000 Received: from [10.9.9.210] (helo=mailfront10.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1eHhDe-0000Hh-Od; Thu, 23 Nov 2017 03:26:26 +0100 Received: from 32.109.34.95.customer.cdi.no ([95.34.109.32] helo=localhost.localdomain) by mailfront10.runbox.com with esmtpsa (uid:757155 ) (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) id 1eHhDY-00070O-MK; Thu, 23 Nov 2017 03:26:20 +0100 Subject: Re: Difference in define behaviour between kawa.jar and embedded Scheme example To: Mark Raynsford , kawa@sourceware.org References: <20171122223308.6b39e57d@copperhead.int.arc7.info> From: Per Bothner Message-ID: Date: Thu, 23 Nov 2017 02:26:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171122223308.6b39e57d@copperhead.int.arc7.info> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-q4/txt/msg00041.txt.bz2 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. 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 per@bothner.com http://per.bothner.com/