All the Perl that's Practical to Extract and Report

Navigation

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Without JavaScript enabled, you might want to
use the classic discussion system instead. If you login, you can remember this preference.

I've read through that a number of times and I think they're right. There are, however, a couple of key differences. First, they don't have state with their traits (see bottom of page two in Traits: Composable Units of Behaviour [unibe.ch]). I think that's a mistake and so does Perl 6 and Moose. Smalltalk traits only share behavior, not data.

I agree the local class overriding role can seem confusing, but over the past few years of using roles pretty heavily I have come to appreciate this feature quite a lot. It actually makes the roles more re-usable since it is very easy to locally override something. Yes it does destroy some of the black-box-ness of Roles, but honestly I have not found roles to be very useful unless you can look inside and see what they provide/do. I have come to kind of see Roles as being more semi-transparent then opaque,

I thought that part of the point of having traits flatten at compile time was to require that kind of override to have explicit disambiguation. So you can locally override, but it's called out in the code.

When traits/roles are applied to classes the local class overrides the role, but the role overrides the superclass. When traits/roles are applied to other traits/roles they are merged together into a composite role and that is where this kind of disambiguation is needed. This cookbook recipe [cpan.org] shows both aliasing and exclusion of role methods, this is a feature directly taken from the traits papers but which Perl 6 has not decided to include.

This cookbook recipe shows both aliasing and exclusion of role methods, this is a feature directly taken from the traits papers but which Perl 6 has not decided to include.

You know, I was wondering why I hadn't seen that in Perl 6. What does that last bit mean, though? That Perl 6 is not yet decided or that they've decided not to offer this? (I'll try and reread the spec tomorrow)