Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^4: strange error when subclassing packages (not use vs require)

by Aristotle (Chancellor)
on Apr 21, 2003 at 02:50 UTC ( #251918=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: strange error when subclassing packages
in thread problem using Class::Factory

You are wrong. Perl will search up the inheritance tree for class methods. The only time it will only look in a single package is using the syntax $foo->Bar::baz() or Foo->Bar::baz(), which will pass a $self of $foo or "Foo", respectively, but invoke the method in the Bar package.

You are also wrong about import(); it is the entire point of OO not to have to sully someone else's namespace with your own symbols.

You would also have easily found out that your assumption is wrong in this case if you had cared to look at the Class::Factory source - no import() function is defined nor is any exporter used.

Makeshifts last the longest.

  • Comment on Re^4: strange error when subclassing packages (not use vs require)

Replies are listed 'Best First'.
Re: Re^4: strange error when subclassing packages (not use vs require)
by pfaut (Priest) on Apr 21, 2003 at 12:50 UTC
    The only time it will only look in a single package is using the syntax $foo->Bar::baz() or Foo->Bar::baz(), which will pass a $self of $foo or "Foo", respectively, but invoke the method in the Bar package.

    Ok, I see where I had it wrong. Derived::foo() would not find Base::foo() but Derived->foo() would.

    You are also wrong about import(); it is the entire point of OO not to have to sully someone else's namespace with your own symbols.

    I understand that completely. I was just pointing out that the manner in which the routine was being invoked might not work without the import. Unfortunately, I was wrong. Sorry to muddy the waters.

    90% of every Perl application is already written.
    dragonchild

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2021-06-22 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (102 votes). Check out past polls.

    Notices?