Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Some Insights from a Traveler Between Languages

by skyknight (Hermit)
on Apr 23, 2005 at 22:24 UTC ( [id://450837]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Some Insights from a Traveler Between Languages
in thread Some Insights from a Traveler Between Languages

Polymorphism, in my mind, refers to the ability for variances in behavior to occur under the hood. Perhaps the best example of this is virtual methods in C++ (or, in fact, the way all methods are invoked in Java). When you have a statement that invokes such methods, and you're doing it on a pointer of a base class type, you have one chunk of code that results in myriad different operations. A homograph, I think, is a bit different. In the case a homograph, you actually need to know what is happening and you have to read the entire sentence to figure that out. In the case of polymorphism, those differences are hidden to you, and in this particular context you are indifferent to them.
  • Comment on Re^4: Some Insights from a Traveler Between Languages

Replies are listed 'Best First'.
Re^5: Some Insights from a Traveler Between Languages
by Joost (Canon) on Apr 23, 2005 at 22:56 UTC
    I was actually having something a bit broader than C++ virtual methods in mind. Sorry about the fuzzyness. What I was thinking about is that in OO programming, you can use the same method name in multiple unrelated classes that might or might not be involved in polymorphism.

    Now, in C++ you still need some kind of type specification for variables, but for Perl or Ruby (or even Java, if you don't mind a lot of introspection) you don't have to, which implies that the actual meaning of the "word" (method name) is entirely dependent on the context. You don't even need OO to achieve this: importing a method from another namespace, or including C header files basically boils down to the same thing.

    Sure it can cause confusion, but can we actually do any better? Human language really is much more adept at disambuigating short words that might have multiple meanings vs reading reallyLongDescriptiveOnesThatGetIncrediblyDifficultToTypeRightAllTheTime. :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found