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]

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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]