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

Perl only has two homographic built-ins: select and for/foreach, so that's not too bad. For/foreach actually do more or less the same thing, so I don't mind them at all, but select really was a mistake IMO.

By the way, is there difference between a homograph and polymorphism?

  • Comment on Re^3: Some Insights from a Traveler Between Languages

Replies are listed 'Best First'.
Re^4: Some Insights from a Traveler Between Languages
by skyknight (Hermit) on Apr 23, 2005 at 22:24 UTC
    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.
      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. :-)

Re: Some Insights from a Traveler Between Languages
by jonadab (Parson) on Apr 25, 2005 at 12:58 UTC
    By the way, is there difference between a homograph and polymorphism?

    Several. For one thing, a homograph is not necessarily also a homophone (though it can be). Also, the different versions of a homograph may be different parts of speech in some cases; as far as I am aware, polymorphism keeps the polymorphic thing as the same part of speech. Furthermore, the idea behind polymorphism, if it's done correctly, is that there is supposed to be a logical connection or parallel between the different versions of it, a way in which, although slightly different, they are "the same"; this is sometimes botched, but it's *supposed* to be there; homographs have no such qualms.

    Homographs like "wind" and "fly" and "record", wherein the meanings are related, are not the nasty ones, IMO. Situations like "that" (which is used as a relative pronoun, as a demonstrative pronoun or adjective, or as a subordinating adverb, and, worst of all, is frequently elided) are the rough ones. Perl as far as I am aware does not have any such pitfalls as that; even the weirdness surrounding pieces of punctuation (notably, commas and curly braces) has nothing on "that".


    "In adjectives, with the addition of inflectional endings, a changeable long vowel (Qamets or Tsere) in an open, propretonic syllable will reduce to Vocal Shewa. This type of change occurs when the open, pretonic syllable of the masculine singular adjective becomes propretonic with the addition of inflectional endings."  — Pratico & Van Pelt, BBHG, p68