This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: define-simple-class feature request: calling inherited methods
- From: Per Bothner <per at bothner dot com>
- To: Vladimir Tsichevski <wowa at jet dot msk dot su>
- Cc: kawa at sources dot redhat dot com
- Date: Thu, 20 Mar 2003 16:19:30 -0800
- Subject: Re: define-simple-class feature request: calling inherited methods
- References: <3E79DDC0.2070408@jet.msk.su>
Vladimir Tsichevski wrote:
in classes defined with define-simple-class etc. it would be useful to
add to the class scope public and protected methods of classes and
interfaces the newly creates class inherits from.
For example, in class inherited from java.awt.Component, in which
enableMask() is protected, it would be possible to write just:
(enableEvents mask)
First we need to have this syntax work for public methods.
The manual says:
The scope of the body of a method includes the field-decls
of the object. It does include the surrounding lexical scope.
It sort-of also includes the declared methods, but this is
not working yet.
Once that works, then it might be reasonable to extend it so that
inherited methods (public or protected) are also in scope.
instead of:
((primitive-virtual-method
<java.awt.Component>
'enableEvents <void>
(<long>))
(this) mask))))
As this example shows, not only will this make code cleaner, but also
allow access to protected members, which is otherwise requires clumsy
and dangerous constructs using primitive-virtual-method.
There is also the alternative:
(invoke (this) 'enableEvents mask)
It might be nice to extend this to it works for protected methods
in ancestors of the current class. We could special-case (this),
though I'd prefer a more general solution.
--
--Per Bothner
per at bothner dot com http://per.bothner.com/