[M3devel] calling an overridden method
Mika Nystrom
mika at async.caltech.edu
Tue Jul 19 16:11:05 CEST 2011
Sorry I'm being confusing here.
The code is right but I think your question is a bit confusing.
With your init example I don't think you're talking about an overridden
init method but a shadowed method. You can't call an overridden method
through the widening trick, but you *can* call a shadowed method like
that.
Mika
Mika Nystrom writes:
>
>TYPE A = OBJECT METHODS m(xxx) END;
>
>TYPE B = A OBJECT METHODS m(xxx) END;
>
>b := NEW(B);
>
>A.m(b,xxx)
>
> Mika
>
>Hendrik Boom writes:
>>I have a module containing a parent class, and another containing a
>>child class.
>>
>>The parent class contains a method 'foo', which is to be overridden in
>>the child class.
>>
>>But in implementing 'foo' in the child class I want to call the parent's
>>method.
>>
>>Now with the method 'init' there's a trick where in the child's init,
>>you WIDEN self to the parent's type and then call its init.
>>This works because 'init' isn't overridden in an OVERRIDES clause,
>>but is defined as a new method that happens to have the same name.
>>
>>Is there any way to do this with 'foo', where the whole point is that
>>it be an overridden method and not a new one?
>>
>>Do I have to do something like covertly exporting the PROCEDURE that
>>implements 'foo' in the parent's module so that it can be called
>>directly? That would seem to be a violation of modular design. Or is
>>violating modular design exactly what I'm really trying to do here?
>>
>>-- hendrik
More information about the M3devel
mailing list