Installing a metalink on a subclass not overriding a method

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Installing a metalink on a subclass not overriding a method

Peter Uhnak

Imagine the following:

 

I have a class ‘Parent’ which has the following method

 

Parent>>name: aString

    name := aString

 

I also have a subclass of a Parent called Child.

Now I would like to attach some behavior via MetaLinks for the method ‘name:’ but only for the Child method, is that possible?

 

Naturally I could just override the method and have

Child>>name: aString

    super name: aString

 

And then attach the metalink to that, but that’s not nice because you have to create extra methods (which is extra work/code if Parent has more subclasses)

 

Alternatively I could attach the MetaLink to Parent and do type-checking, but that would br very complex and error-prone (Parent has a rather wild family).

 

Ideally I would like for the MetaLink to install to the child even though the method doesn't exist. Is that somehow possible?

 

Thanks,

Peter