2010/3/19 Chris Fields <[email protected]>: > On Mar 19, 2010, at 5:01 PM, Robin Smidsrød wrote: > >> On 19.03.2010 19:38, Jesse Luehrs wrote: >>> On Fri, Mar 19, 2010 at 06:32:36PM +0000, Ævar Arnfjörð Bjarmason wrote: >>>> On Fri, Mar 19, 2010 at 18:28, Jesse Luehrs <[email protected]> wrote: >>>>> Um... did you actually try to run this code? Because it already does >>>>> exactly what you are trying to do. >>>> >>>> Actually it doesn't. >>>> >>>> I'm guessing that the problem here is that he's calling A->extends() >>>> in the B package instead of extends("A"); >>> >>> Which causes perl to die with a recursive inheritance error (since >>> A->extends() is equivalent to A::extends('A')), so I'm assuming that his >>> actual code isn't doing that. >> >> I assume that the solution is to change A into this: >> >> package A; >> use Moose; >> no Moose; # <-- Added this >> 1; >> >> With that in place the call to A->extends() would fail with an invalid >> method call during runtime. >> >> But 'no Moose' isn't mandatory, as far as I know, which means that his >> example seems to be a good test case for a really obscure edge case. >> >> -- Robin > > The Moose docs implicitly state that extends() should be called using the > class as a string and not as a symbol (the latter which triggers the indirect > object call): > > extends 'Point'; > > Maybe the docs need to be updated to state that explicitly (and indicate why)? > > chris
Well... A) This wasn't the problem the original poster had. He simply hadn't run the example code to test his theory. B) The error message Moose spits out in such a case is pretty descriptive: $perl -Moose -E'package Example; extends Class;' Recursive inheritance detected in package 'Class' at /Users/perigrin/.perlbrew/perls/current/lib/perl5/darwin-2level/Class/MOP/Class.pm line 563. C) If you feel that A and B aren't sufficient, please send me an SSH key and I'll provide you access to make such a patch. -Chris
