This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: OOP with Kawa
- From: Per Bothner <per at bothner dot com>
- To: JÃrÃme Brilland <jeromebri at gmx dot fr>, kawa at sourceware dot org
- Date: Mon, 01 Dec 2014 12:22:58 -0800
- Subject: Re: OOP with Kawa
- Authentication-results: sourceware.org; auth=none
- References: <547CCBEB dot 2090803 at gmx dot fr>
On 12/01/2014 12:13 PM, JÃrÃme Brilland wrote:
I get the following warnings :
test3.scm:22:25: warning - no known slot 'name' in java.lang.Object
test3.scm:22:32: warning - no known slot 'x' in java.lang.Object
test3.scm:22:36: warning - no known slot 'y' in java.lang.Object
The Kawa documentation lacks examples.
True. It also needs a tutorial.
Could someone provide me with OOP examples ?
Actually, your example is fine. If you put it in a file ob.scm,
then run Kawa is whole-file-mode, you get no warnings:
$ kawa /tmp/ob.scm
creating class...
farm : (5, 7)
farm : (6, 7)
If you run in line-at-a-time module you get warnings,
but it still works:
$ kawa -f /tmp/ob.scm
creating class...
/tmp/ob.scm:21:25: warning - no known slot 'name' in java.lang.Object
/tmp/ob.scm:21:32: warning - no known slot 'x' in java.lang.Object
/tmp/ob.scm:21:36: warning - no known slot 'y' in java.lang.Object
farm : (5, 7)
/tmp/ob.scm:23:25: warning - no known slot 'name' in java.lang.Object
/tmp/ob.scm:23:32: warning - no known slot 'x' in java.lang.Object
/tmp/ob.scm:23:36: warning - no known slot 'y' in java.lang.Object
farm : (6, 7)
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.
--
--Per Bothner
per@bothner.com http://per.bothner.com/