in reply to Moose, @ISA and method resolution

First off, many thanks for taking the time to answer so many questions about Moose Stevan. It's appreciated by all of us. So a big thanks from me.

Next, I am happy to say that after a nice 6 or more day learning experience (Yeah, that's embarrassing) I've finally determined what's going on. I finally boiled this down to a minimal test case and realized that the code isn't doing what I think the code is doing. MO=Deparse showed that instead of calling Program::Plist::Pl::Pattern->new, I was calling Pattern()->new().

As it turns out, I have a MooseX::Types definition for a Pattern type. At the top of the Pl.pm file, I use Program::Types qw(Pattern) Which means I have now imported a subroutine into my package that has the SAME fully qualified name as my package I'm trying to instance. So when I said Program::Plist::Pl::Pattern->new(), Perl thought I wanted to call the Pattern subroutine &Program::Plist::Pl::Pattern()(which is why I'm off in MooseX::Types land in the debugger) and then call the new method of the result.

I'll post some code tidbits of my mistake here tomorrow in the hope it may help someone else not make the same mistake :)

Replies are listed 'Best First'.
Re^2: Moose, @ISA and method resolution
by stvn (Monsignor) on Jan 13, 2011 at 02:36 UTC

    Excellent, I am glad to hear you solved it. I will point out again that if you had posted the code to the Pattern class, we probably would have been able to save you those 6 days of debugging :)

    This exact issue is why I do not use MooseX::Types and probably never will (and why it has not become part of Moose core). While it is nice to have compile time checking of type names, it is at the expense of twisting perl's arm and trying to make types look like barewords. Some magic is just not worth it.

    -stvn
Re^2: Moose, @ISA and method resolution
by tilly (Archbishop) on Jan 13, 2011 at 15:38 UTC
    One solution, though it looks ugly, is to call Program::Plist::Pl::Pattern::->new(). This disambiguates between the package and any possible function of the same name as the package.

      This is quite true, and another reason why MooseX::Types won't get into core Moose. In my opinion it is unacceptable to put the burden of change on the user like this.

      -stvn