I have an issue I'm debugging that is making me question my somewhat limited understanding of method resolution. The below Pl and Pattern classes are Moose classes utilizing MooseX::Types and MooseX::Params::Validate.

First, here's the line where things go haywire in the debugger (apologies for width):

DB<18> . Program::Plist::Pl::_create_pattern_obj(/nfs/pdx/disks/nehalem.pde.077 +/projects/lib/Program-Plist-Pl/lib/Program/Plist/Pl.pm:62): 62: my $pattern_obj = Program::Plist::Pl::Pattern->new(name => + $name, 63: mask_da +ta => $mask_data, 64: tags => + $tags);

This call should first check the Program::Plist::Pl::Pattern symbol table for a new entry. Here's our symbol table:

DB<3> print Dumper(\%Program::Plist::Pl::Pattern::); $VAR1 = { 'import' => *Program::Plist::Pl::Pattern::import, 'meta' => *Program::Plist::Pl::Pattern::meta, 'ISA' => *Program::Plist::Pl::Pattern::ISA, 'BEGIN' => *Program::Plist::Pl::Pattern::BEGIN, 'isa' => *Program::Plist::Pl::Pattern::isa };

Ok, no new entry here. Next step should be checking Pattern's @ISA for parents:

DB<4> print Dumper \@Program::Plist::Pl::Pattern::ISA $VAR1 = [ 'Moose::Object' ];

We have Moose::Object as a parent. Next step should be checking to see if this parent class has a 'new' entry in its symbol table (some entries deleted for readability):

DB<6> print Dumper \%Moose::Object:: $VAR1 = { '__mx_is_compiled' => *Moose::Object::__mx_is_compiled, 'new' => *Moose::Object::new, 'DOES' => *Moose::Object::DOES };

Ok, it appears that we have a new entry for Moose::Object. At this point, I would assume that &Moose::Object::new(@args) would be called. I have a locally modified version of that library that prints args when called. Let's make certain it works:

DB<14> &Moose::Object::new('arg1'); MOOSE->NEW CALLED WITH ARGS (arg1) Can't locate object method "BUILDARGS" via package "arg1" (perhaps you + forgot to load "arg1"?) at /nfs/pdx/disks/nehalem.pde.077/debug/Moos +e/Object.pm line 25, <$fh> line 8.

Ok, verified that my code does print when the Moose::Object::new method is called. Let's execute our problem line and see what happens. First, our line is:

DB<1> c Program::Plist::Pl::_create_pattern_obj(/nfs/pdx/disks/nehalem.pde.077 +/projects/lib/Program-Plist-Pl/lib/Program/Plist/Pl.pm:62): 62: my $pattern_obj = Program::Plist::Pl::Pattern->new(name => + $name, 63: mask_da +ta => $mask_data, 64: tags => + $tags);

And issuing a single step command to the debugger results in this:

DB<18> s MooseX::Types::EXPORTED_TYPE_CONSTRAINT=CODE(0x1ec2ca8)(/nfs/pdx/disks +/nehalem.pde.077/debug/MooseX/Types.pm:386): 386: my $type_constraint = $class->create_base_type_constra +int($name);

How did I get to MooseX::Types::EXPORTED_TYPE_CONSTRAINT? I don't see the output for Moose::Object::new at all, meaning I didn't get there. How have I short circuited the symbol table lookups to get to this code? Is my understanding of how a method is found wrong? My inability to trace this code has made debugging my issue very difficult.

It would appear this code is being called to deal with the arguments to the Pattern->new call, but I see no functions in the arguments to the call.


In reply to Moose, @ISA and method resolution by tj_thompson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.