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: OOP with Kawa




On 12/02/2014 02:31 PM, JÃrÃme Brilland wrote:
Now I am trying the define-class syntax, but I get errors :

(define-class <moveable>()
     (x type: int)
     (y type: int)
     ((move ax ay)
         (displayln "moving object...")
         (set! x ax)
         (set! y ay)
         )
     )

(define-class <unit> (<moveable>)
     (strength type: int)
     (name type: string)
     )

(define u :: <unit>
     (<unit>
         x: 6
         y: 17
         name: "warrior"
         strength: 100
         )
     )

(printf "~A : (~D, ~D) : ~D" u:name u:x u:y u:strength)(newline)
(u:move 11 12)
(printf "~A : (~D, ~D): ~D" u:name u:x u:y u:strength)(newline)

Please always submit a complete self-contained test case if at all possible.
Use an attachment if there is any chance formatting might get screwed up.
Also include instructions - .e.g. what commands you used.

Specifically, I had to replace (printf ...) by (format #t ...)
and displayln by display.

But I get the following errors :

test4.scm:40:30: caught exception in inliner for #<procedure gnu.kawa.functions.GetNamedPart> - java.lang.NoClassDefFoundError: atInteractiveLevel$3
     java.lang.Class.getDeclaredClasses0(Native Method)
     java.lang.Class.getDeclaredClasses(Class.java:1766)
     java.lang.Class$2.run(Class.java:1354)
     java.security.AccessController.doPrivileged(Native Method)
     java.lang.Class.getClasses(Class.java:1348)
     gnu.bytecode.ClassType.addMemberClasses(ClassType.java:241)
     gnu.bytecode.ClassType.getDeclaredClass(ClassType.java:166)
     gnu.kawa.reflect.SlotGet.lookupMember(SlotGet.java:229)

I don't see this.  Is it possible you're using an old version?
It's usually best to build from source checked out from svn.
Or wait for 2.0, which I intend to release this evening ...

When I run *without* the -f option then I see warnings:

/tmp/bar.scm:17:5: warning - no field or setter 'x' in class bar$unit$class
/tmp/bar.scm:17:5: warning - no field or setter 'y' in class bar$unit$class

I think this is a bug because Kawa doesn't handle not-yet-compiled classes
in this case.  That needs to be fixed ...

I really would like a few examples...

There are some in the Kawa source code.  If you have the Unix-style tools
available, look for them with grep+find:

$ grep define-simple-class `find . -name '*.scm'`
$ grep define-class `find . -name '*.scm'`

I do hope to spend some time on the Tutorial fairly soon,
and I'll try to come up with step-by-step simple examples.

--
	--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]