Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: The world is not object oriented

by Corion (Pope)
on Jan 02, 2004 at 15:27 UTC ( #318331=note: print w/ replies, xml ) Need Help??


in reply to Re: The world is not object oriented
in thread The world is not object oriented

Yes, that's how polymorphism is implemented in C++. But it doesn't have to work like that. Perl's bless'd objects, for instance, does polymorphisim by walking the inheirtance tree (not that this is a great way to do it--it's slow).

No. The inheritance tree is called that, because it is used for implementing inheritance, not polymorphism. Polymorphism means you have several things, that you can treat in a uniform way, for example because they all implement the same interface. Polymorphism is (for example) usefull, when you are storing objects in a container, and the container somehow has to interact with its objects.

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web


Comment on Re: Re: The world is not object oriented
Download Code
Re: Re: Re: The world is not object oriented
by hardburn (Abbot) on Jan 02, 2004 at 16:34 UTC

    The inheritance tree is called that, because it is used for implementing inheritance, not polymorphism. Polymorphism means you have several things, that you can treat in a uniform way, for example because they all implement the same interface.

    Subclasses, in general, have the same interface as their parents, which means that polymorphism and inheirtance are tightly bound.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

      Yes and no. It's exceedingly difficult to have inheritance without polymorphism but it's exceedingly useful to have polymorphism without inheritance. Polymorphism is the principle. Inheritance is one application.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (15)
As of 2014-07-28 20:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (207 votes), past polls