This is the mail archive of the kawa@sources.redhat.com 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]

Re: define-simple-class feature request: calling inherited methods


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/



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