NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Is it a bug or a feature? (Score:1)
Not completely into Moose yet, but isn't a role the equivalent of a Java interface?
In that case, the behaviour you describe has been implemented there as a intended feature: a regular class *implements* the interface.
Additionally, a role seems to also have the function of an abstract class as well. In Java, overriding concrete methods is, again, a feature you want.
If you don't want to override a method simply do not include a overloading method in the implementing class.
It looks like a (sensible) design dec
Re: (Score:2)
Roles are far more than interfaces. I strongly recommend reading up on them to understand what they do. The protect (usually) against method collision and they provide a default implementation. If you want to use one like an interface, it's simple:
And now your classes (or some other role composed into said classes) must provide save and search methods.
However, if you have this:
Re: (Score:1)
So it's indeed also like an Abstract class in Java. The solution for the problem in the Java world is the @Override annotation before the overriding method.
It overrides silently, but it's clear in your code and your IDE will warn you if you don't add the @Override annotation.
Something like that would indeed save debugging time.
C.
Re:Is it a bug or a feature? (Score:1)
A role is like an abstract class in Java in the same way lightning is like a lightning bug.
Reply to This
Parent