This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
non-default init methods in define-simple-class
- From: Per Bothner <per at bothner dot com>
- To: kawa at sources dot redhat dot com
- Date: Fri, 14 Oct 2005 00:52:52 -0700
- Subject: non-default init methods in define-simple-class
I finally got around to implementing a long-requested feature:
explicit constructor methods for define-simple-class.
I decided to use the special name '*init*' for such methods:
(define-simple-class <Triple> (<gnu.lists.Pair>)
(aux)
((getAux) aux)
((*init* a b c)
;; Following is like Java's: super(a,b)
(invoke-special <gnu.lists.Pair> (this) '*init* a b)
(set! aux c))
((*init* val)
;; Following is like Java's: this(val,val,val)
(invoke-special <Triple> (this) '*init* val val val)))
Call this- and super-constructors can be done using
invoke-special. This is a bit klunky, but it works.
A better (future) syntax might be:
(*super* a b)
(*init* val val val)
This is in CVS. It's an important-enough feature that I think
it's worth re-spinning Kawa 1.8, while we're waiting for the FSF.
--
--Per Bothner
per@bothner.com http://per.bothner.com/