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-simple-class vs modules


On 01/25/2011 03:49 PM, Per Bothner wrote:
On 01/25/2011 02:25 PM, Jamison Hope wrote:
Once upon a time (before 1.10, probably), I was able to do something
like this:

$ cat Test.scm
(define-simple-class Test ()
((*init*) (display "Created an instance") (newline)))

but now when I try to compile it:

$ java kawa.repl -C Test.scm
(compiling Test.scm to Test)
Test.scm:2: internal error while compiling Test.scm
java.lang.Error: calling <init> on already-initialized object
at gnu.bytecode.CodeAttr.emitInvokeMethod(CodeAttr.java:1498)

It seems I can no longer define-simple-class a Java class with the name
of the Scheme file. That name gets reserved for a mandatory "module"
class, even if the simple-class is the only definition in the whole
file. Was it just an accident that it worked before?

Basically. It might work in some cases, but could easily break. In fact, relatively recently I made changes just so this *should* work more generally. And it does, if you leave out the *init*.

Haven't yet figured out why the *init* is causing problems,
but am looking into it.

The problem was confusion between the automatically-generated default constructor for the module class, and the explicit constructor in the declared class. They clashed.

I checked in a fix.
--
	--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]