This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: OOP with Kawa
- From: JÃrÃme Brilland <jeromebri at gmx dot fr>
- To: kawa at sourceware dot org
- Date: Tue, 02 Dec 2014 23:31:45 +0100
- Subject: Re: OOP with Kawa
- Authentication-results: sourceware.org; auth=none
- References: <547CCBEB dot 2090803 at gmx dot fr> <547CCE22 dot 9090307 at bothner dot com>
Hello,
On 01/12/2014 21:22, Per Bothner wrote:
To shut up the warnings, Kawa needs to be able to deduce that f
is a <building> - and can't be changed to something else. So either
use define-constant:
(define-constant f
(<building>
x: 5
y: 7
name: "farm"))
or add a type specifier:
(define f :: <building>
(<building>
x: 5
y: 7
name: "farm"))
or just run in whole-file (module) mode.
Thanks !
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)
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 really would like a few examples...
JÃrÃme