Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Inheritance confusion

by splinky (Hermit)
on May 20, 2005 at 19:01 UTC ( [id://459094]=note: print w/replies, xml ) Need Help??


in reply to Inheritance confusion

I think if you look at the code for Net::FTP, you'll find your answer, as Net::FTP inherits from IO::Socket::INET. As another poster mentioned, you're implementing your subclass as a hash, whereas Net::FTP is implemented as a typeglob. That's what's causing the problem. One of the weaknesses of Perl's OO implementation is that you have to know a class's internal representation in order to inherit from it.

Anyway, look in the code for Net::FTP and see how its constructor works, and implement yours the same way.

Replies are listed 'Best First'.
Re^2: Inheritance confusion
by revdiablo (Prior) on May 25, 2005 at 17:19 UTC
    One of the weaknesses of Perl's OO implementation is that you have to know a class's internal representation in order to inherit from it.

    Actually, this is not strictly true. He could use an inside-out-object-like design, and avoid using the object reference to store the data at all. He could initialize the object using the original constructor, and rebless it into his package. Voila, inheritance without knowing about the parent's internal representation. By the way, I am not saying this is the best design in these circumstances, only that it is possible.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found