|
Problem:
You want to prevent subclasses -- or anyone else -- from changing the interface of a method. In other words, you want all implementations of the method, in all subclasses, to match the same method signature. Solution:
Use the
Discussion: In perl5, methods of a class (package) were rather squirrely things. When you overrode a parent's method in a subclass, you just overrode it: it was up to you to verify that the signatures of the two methods matched, if you wanted them to. This older philosophy is still available, and is in fact still the default behavior of methods. In perl6, the concept of interface methods is more explicitly supported. The It is especially useful to assign the If you want to be able to change the signature of a particular method in subclasses, no problem: just declare it the normal way, without As a special case, it is always allowable to add extra, optional arguments to an overriden interface. This allows individual subclasses to define "more detailed" behavior of an interface method -- behavior that other subclasses don't need to know about. Issue: Should there be an optional 'strict'ness that implies all methods in all classes are interface methods, without having to say it in every class?
|