lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

on 1/19/05 9:02 AM, PA at wrote:

>> . The syntax to call inherited methods
> What about something like: anInstance:super:doIt()?

That would only work for one level of inheritance.

Maybe the C++ approach of explicitly naming the parent class has some merit,
though it also has maintenance issues. Those issues could be handle by
defining a local variable named something like "super" at the beginning of a
class declaration.

What gets more interesting is when one builds a multiple inheritance system
that sequences the super classes. Then the next method (as opposed to the
inherited method) depends on the over all chain. For example, given classes
A and B as base classes for multiple-inheritance, it might be interesting to

    function A:method( param )
        call_next_method( self, A, "method", param )
        self.field = param

One could also write an implementation for B that did appropriate chaining
and get different results depending on whether one descended from A and B or
B and A.