On Jan 6, 2011, at 7:08 AM, David Leadbeater wrote:
On Thu, Jan 06, 2011 at 06:58:35AM -0500, Stevan Little wrote:
I think currently DOES support is located in Moose::Object, seems
like a
good idea to add support for it in the Meta Role too.
The behaviour depends on if UNIVERSAL::DOES is implemented by the
version of perl too. On 5.12 Ovid's script prints "11", i.e. DOES is
implemented but a role does not do itself. Seems like the behaviour
should be consistent between perl versions to me.
Adding pre 5.12 support for UNIVERSAL::DOES is pretty easy and in fact
the support for DOES in Moose::Object first looks to see if you have a
UNIVERSAL::DOES in it.
That said, I looked again at the source for that and I am not sure
this is appropriate for roles.
DOES checks role-ness, but it also checks ->isa as well, to quote the
docs:
DOES and isa are similar, in that if either is true, you
know that the object or class on which you call the method
can perform specific behavior.
...
In other words, by default DOES responds identically to isa.
This is consistent with chromatics allomorphically heavy view of
things, but is in contrast with the Moose handling of &does.
So actually I retract my original agreement to Ovid and agree with
David now, given that DOES also includes ->isa checks (by design) I
think it is not appropriate, and potentially confusing, for roles to
support it.
(*sigh* - this will teach me to comment on mailing list posts before
my morning coffee)
- Stevan