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)
For a definition of "silently" which means "Code I explicitly wrote in my class itself", perhaps.
What if you extracted all behavior into roles and composed them into classes? I think that would produce the desired results.
Re: (Score:1)
Re: (Score:1)
If you override a method in OO code (the paradigm under discussion) explicitly, you get no warning or error.
Changing this default behavior is like resolving method dispatch at compile time. That's fine for certain languages, none of which have "Perl" in their names.
Re: (Score:1)
Re: (Score:1)
Class-local overriding of composed role methods is a standard technique too. It's been in the Perl 6 role specification for years. I have code which relies on it -- and that code predates Moose.
I fail to understand the value of adding a default warning for intended, specified, useful behavior -- especially behavior you can't accidentally back into.
Re:Is it a bug or a feature? (Score:1)
FWIW, I agree with you, however a warning cannot hurt and can possibly make it easier to spot problems during heavy role refactoring. And if we find it is more annoying then expected and/or not as helpful as expected, we can remove it as easily as we put it in. The decision made on #moose was that it was a simple enough change and an innocuous enough thing that it was at least worth giving a try. Roles are still a new "thing" and so I still feel like we are exploring some unknown territory here even after using and exploring them for almost 5+ years now (I released Class::Trait 0.01 in 2004).
- Stevan
Reply to This
Parent
Re: (Score:1)
That's completely untrue. This particular warning may not hurt (I don't believe that, but I acknowledge the possibility), but warnings can hurt. I should write a longer post about this. For now, consider take Vista's UAC for examples of supposedly helpful warnings that do, in fact, hurt.