This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: define-syntax and define-simple-class


David O'Callaghan wrote:
;MyAdd.scm
(define-op (MyAdd a b) (+ a b))

I can compile MyAdd.scm with "kawa -f MyMacro.scm -C MyAdd.scm". The
;MyAddTest.scm
(define a (MyAdd:new))
(define operands (<java.lang.Object[]> 1 2))
(display (a:execute operands))(newline)

However, running "kawa -f MyAddTest.scm" I get the error:

java.lang.NoSuchFieldError: lambda$Fn1

The problem is that MyAdd.scm compiles to a module class named MyAdd.class. This conflicts with the class created by the define-simple-class. Kawa doesn't catch this error.

One solution is to renamed MyAdd.scm, or change the module class name
using either the -T option, or the module-name declaration.

I'd guess there is some inconsistency in name mangling for the lambda
function.

No, it's just confused because two classes have the same name - which of course is not allowed.

I made the following change:

--- kawa/standard/object.java   (revision 5972)
+++ kawa/standard/object.java   (working copy)
@@ -282,6 +282,8 @@
          { // Method declaration.
            Pair mpair = (Pair) pair_car;
            Object mname = mpair.car;
+          while (mname instanceof SyntaxForm)
+               mname = ((SyntaxForm) mname).form;
            if (! (mname instanceof String)
                && ! (mname instanceof Symbol))
              {

This is probably a reasonable patch.

Now when I try to compile with "kawa -f MyMacroPrivate.scm -C MyAddPrivate.scm" I get:

MyAddPrivate.scm:1:1: warning - simple class requiring lexical link -
use define-class instead
MyAddPrivate.scm:1:1: missing implementation for
MySuper.execute(java.lang.Object[])java.lang.Object mname:execute
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]