in reply to Some Insights from a Traveler Between Languages

but is it worth it?
I absolutely appreciate the terseness of:
if (@foo) { ... there's something in @foo .. }
and
while (@todo) { ... do something while there's somethign to do ... }
I think the whole context thing is an elegant solution, and mimics what we do naturally in human languages. Quick.. how do you pronounce "record"? Or "wind"? Can't tell, until you get the rest of the sentence. Yet we handle that just fine.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: Some Insights from a Traveler Between Languages
by tlm (Prior) on Apr 23, 2005 at 17:33 UTC

    But, paradoxically, even though it mimics human languages, humans seem rather prone to slip on Perl's use of context. In contrast, the lack of context dependance in other languages may be somewhat inconvenient but is not a banana peel. My point is to question the notion that this particular feature makes Perl somehow more in tune with the way humans think.

    the lowliest monk

      Funny, though, that you didn't write:

      My point are to questions the notion that this particular features make Perl somehow more in tune with the way human thinks.

      There are some corner cases in English where subject-verb number agreement is difficult, but I know a lot of people who do pretty well with it. Why should it be any more difficult?

        Maybe it is just as difficult, and that's precisely the problem. Just because some people can learn a particular set of rules and become proficient with them doesn't mean they constitute a good system; consider the Roman numerals, for example.

        For the most part I have become sufficiently accustomed to Perl's context scheme that I am not particularly inconvenienced by it, but I know many who struggle with it, and I can't help but notice the irony.

        Esprit de l'escalier: Another objection to the subject-verb agreement errors analogy is that such errors are benign, in the sense that they rarely, if ever, lead to serious misunderstandings (if they did they would have been weeded out of the language long before the appearance of the first grammarians). In contrast, context-related errors in Perl are not benign.

        the lowliest monk

Re^2: Some Insights from a Traveler Between Languages
by skyknight (Hermit) on Apr 23, 2005 at 20:45 UTC
    I appreciate its terseness as well, but it's a doubled-edged sword. Also, it's not clear to me why you are citing homographs as a defense. To me, it seems that homographs are a misfeature of natural language, resulting from the fact that natural languages are the product of clumsy evolution and combination over the course of eons. Clearly it would be better if languages didn't have homographs as it makes life more difficult needlessly. Yes, we can handle them, but they don't buy us anything, so why should we use that kind of thing as an argument when deliberately designing artificial languages?
      Well, it's easy to come up with egregious examples and show how English could have been better designed, but you overgeneralize. The fact is that we rely on multimethod dispatch all the time in any natural language, and it's just a minor lexical miracle that you don't even notice that you're using homophones with different meanings:
      The chicken is ready to eat.
      The children are ready to eat.
      In short, you're relying heavily on MMD yourself when you use overloaded words like:
      appreciate well clear product clumsy combination course as makes life handle buy should use kind argument
      MMD is useful because it lets you express metaphorical correspondences. To trot out the Inkling's favorite example, a "piercing sweetness" may be neither piercing nor sweet, literally speaking, but your MMD dispatcher is even smart enough to autogenerate missing methods and dispatch to them.
        Yes, we humans do manage to deal with the vagaries of natural language, but I don't really see this fact as being a good defense of similar issues cropping up in artificial languages. Why do we have programming languages for developing software at all? It's because specifying the solutions to engineering problems is damned near impossible in English, at least when it comes to the nitty-gritty details. We need programming languages for the precision with which they allow us to specify the operation of systems. Anything that goes against this end ought to be considered a misfeature.
        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
        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^2: Some Insights from a Traveler Between Languages
by Anonymous Monk on May 18, 2005 at 04:56 UTC
    But the python version is slightly shorter...
    if foo:           # empty list [] evaluates to False
       do_something()
    
    and
    while foo:
       x = foo.pop()
       do_something(x)
    
    Cheers, --OH.