Perl-Sensitive Sunglasses | |
PerlMonks |
Re^2: Moose "unions" and inheritanceby PetaMem (Priest) |
on Nov 30, 2012 at 11:42 UTC ( [id://1006463]=note: print w/replies, xml ) | Need Help?? |
Thanks a lot for this example. Many lessons learned. :-) Starting to grok the code, I 1st wondered why the type constraints do not need to be written in a string. It seems use MooseX::Types::Moose is responsible for being able to do that. I wondered if it will "do the right thing" if confronted with multiple inheritance and added a "JustTesting" class like so
and then of course used extends 'KeyAtom', 'JustTesting'; in the ValAtom class definition. A subsequent my $atom4 = ValAtom->new(sub {}); throws an error
Indicating, that only the 1st one in the inheritance hierarchy gets propagated. So I assume for it to work independent of how many parent classes were passed, one would have to loop over them in _existing_constraint (how?) and buildup the type constraint before returning it. Thanks also for the +data hint, that somehow fell of my stack. Although I ask myself what happens if a inheriting class uses +data and some parents have 'rw' while others have e.g. 'ro'.Bye
In Section
Seekers of Perl Wisdom
|
|