This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: r7rs libraries question
- From: Per Bothner <per at bothner dot com>
- To: Jeff Gonis <jeff dot gonis at gmail dot com>, kawa at sourceware dot org
- Date: Mon, 10 Nov 2014 23:45:35 -0800
- Subject: Re: r7rs libraries question
- Authentication-results: sourceware.org; auth=none
- References: <CAFVyn8TC75s=5EsXZu-fV8kZe_xx_A5xTa0zzu0qi8RNCFAhjw at mail dot gmail dot com> <54606615 dot 30601 at bothner dot com>
On 11/09/2014 11:15 PM, Per Bothner wrote:
I tried inlining the define-library into a single file:
(define-library (lib1)
(import (except (scheme base) square))
(export square)
(begin
(define (square n)
(* n 2))))
(import (scheme base))
(import (prefix (lib1) lib1-))
(display (square 8)) (newline)
(display (lib1-square 8)) (newline)
When I do the following:
$ kawa -f lib1.scm
I get
16
16
as you describe.
This is because of a feature to support interactive redefinition
of functions: When a function f is redefined, we *reuse* the
old Procedure object. The problem is that this is happening
to the Procedure object for the builtin square function.
This is a a bug, but I think about how best to fix this.
When I do the following:
$ kawa -f lib1.scm
That should be been (without a -f):
$ kawa lib1.scm
I get an ExceptionInInitializerError :-(
I will try to figure out what is going on - in both modes.
In the case the problem is because the source file lib1.scm
has teh same name as the library lib1. We generate two classes
with the same name, which confuses things ...
The fix is to rename lib1.scm to something else.
Of course Kawa shouldn't throw an ExceptionInInitializerError -
if we can't implement this case we should at least produce a
compile-time error message.
--
--Per Bothner
per@bothner.com http://per.bothner.com/