Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Invoking bless triggers "Can't resolve method ..." error

by choroba (Cardinal)
on Jul 08, 2015 at 20:48 UTC ( [id://1133805]=note: print w/replies, xml ) Need Help??


in reply to Invoking bless triggers "Can't resolve method ..." error

What is "module-name"? Does that module use overload? What's in $class at the moment of the blessing?
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re: Invoking bless triggers "Can't resolve method ..." error

Replies are listed 'Best First'.
Re^2: Invoking bless triggers "Can't resolve method ..." error
by turkanis (Novice) on Jul 08, 2015 at 21:04 UTC

    Thanks for replying!

    I replaced the name of the parent class with <module-name>. It is a module written by me that does not use "overload" and is currently used as-is in production code.

    The variable $class contains the name of the current package, which is also used as-is in production code and does not use "overload".

    I don't use "overload" much. It appears in my code base only a few times, and none of the uses appears to have anything to do with the line causing the error.

      I replaced the name of the parent class with <module-name>. […] The variable $class contains the name of the current package ...

      I assume that <module-name> is a valid class name. The quoted statements suggest to me that the class <module-name> and the "current package", i.e., class, are not the same. IOW, you are creating an object of class <module-name> and then severing the connection of object data to that class by re-bless-ing the object into a class which has an unknown (to me, at least) relationship to the generating class. This seems to me to be a very good recipe for major Brain Hurt.

      Is there any reason not to use the "standard" instantiation process, i.e., use the new constructor of the parent/base/super class, then add data, etc., to the object appropriate to the child/derived/sub class before returning the object reference?


      Give a man a fish:  <%-(-(-(-<

        I am using the standard instantiation process: creating an instance of the parent class and reblessing it as an instance of the subclass. The two classes are related by ISA. If I didn't do this, methods overridden by the subclass would not be invoked and new methods defined by the subclass would not be resolved.

      The variable $class contains the name of the current package

      How exactly did you inspect the contents of $class? Did you use the debugger or something like Data::Dump, or did you simply print it?

      At this point we're just giving educated guesses; I suggest you boil the problem down to a short, runnable example (see http://sscce.org/) that reproduces the problem.

        Yes, by inspecting it in a debugger

        I am working on "boiling" the problem down, but it is a long process. The error is so strange that I thought someone might be able to tell me what would be the likely cause.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1133805]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-20 00:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found