This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: module extension
- To: mgd at swarm dot org (Marcus G. Daniels)
- Subject: Re: module extension
- From: Per Bothner <per at bothner dot com>
- Date: 24 Nov 2000 00:13:15 -0800
- Cc: kawa at sources dot redhat dot com
- References: <rfiitpeidt7.fsf@cathcart.sysc.pdx.edu>
mgd@swarm.org (Marcus G. Daniels) writes:
> The Kawa manual makes it sound as if it is possible to extend any Java
> class as a Scheme module provided that class has a default
> constructor. Is this really the intent?
Yes.
> If so, should it also
> be possible to make Scheme modules based on Java classes that have
> constructors with arguments?
Yes - but I haven't figured out a syntax for it - let a alone impleemnted it.
There is a good chance it won't get implemented. Instead, Kawa may
get an alternative 'define-class' syntax, which will be an alternative
syntax syntax dfeining classes. I haven't worked this out yet.
> I've attached a test case that tries to do a module-extends in three
> different ways 1) by having a default constructor, 2) by implementing
> Runnable, and 3) by extending gnu.expr.ModuleBody. Only #3 works for
> me. With Sun JDK 1.2.2 and JDK 1.3 on i386 Linux, #1 and #2 result in
> a Verify error like this:
The following patch seems to fix the problem:
Index: Compilation.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/expr/Compilation.java,v
retrieving revision 1.43
diff -u -r1.43 Compilation.java
--- Compilation.java 2000/10/15 18:51:05 1.43
+++ Compilation.java 2000/11/24 08:11:46
@@ -703,7 +703,8 @@
// If immediate, we cannot set the function name in the constructor,
// since setLiterals has not been called yet (except for nested functions).
- if (lexp != null && lexp.name != null && !immediate)
+ if (lexp != null && lexp.name != null && !immediate
+ && curClass.getSuperclass().isSubtype(typeProcedure))
{
constructor_method.compile_push_this ();
compileConstant (lexp.name);
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/