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.
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.
:-)
| [reply] |
|