in reply to Re^8: why does push not default to $_?
in thread why does push not default to $_?

So the default pronoun is the "you" in imperativ forms? I'm sure it can't be so different in Latin ...(e.g. "Vade retro (Satanas)!" )... so thinking Perl has to be unorthogonal because English is, is a little speculative.

"Irregularities" in human languages derrive from abbreviation of frequent constructs, but the rules of abbreviation can be very regular. Only sometimes there are conflicts between regular abbreviation and standard constructs with different meaning, so one need an irregular abbreviation to distiguish the meanings (Can't find an example in English).

These conflicst are unavoidable in languages with a active vocabulary of 30000 words, but computer languages hardly have this extent ... (maybe except inhuman examples like PHP or Cobol ... ; )

Anyway the direct object "it" is the equivalent to $_, the direct object of "push it" is also $_. The reason why the "indirect object" @array is at first place in perl syntax, is because you can't push a list otherwise. Well and this breaks the analogy to English, since AFAIK the direct object has to be at first place...

"push $it,@to_array".

I remeber when I started Perl, I was frequently putting the array at the end of the push parameters! So we see Perl is already not readable the way AppleScript or HyperTalk is (thank God!)

Cheers Rolf

Replies are listed 'Best First'.
Re^10: why does push not default to $_?
by ikegami (Patriarch) on Dec 07, 2008 at 17:34 UTC

    So the default pronoun is the "you" in imperative forms?

    There's no default. It can equally be "you" (singular) and "you" (plural) and "we" (plural).

    Anyway the direct object "it" is the equivalent to $_,

    But the "it" isn't optional. "eat" and "eat it" are not synonymous.

    I'm not sure why you guys are comparing English with Perl. There might be similarities, but the differences are more numerous. It's not helping you at all.

      > There might be similarities, but the differences are more numerous. It's not helping you at all.

      that's what I'm trying to show. Whenever I try to discuss about the inner mechanisms of perl, this myth arises:

      "Perl doesn't have to be logical, it's modelled after a human language"

      These are not contradictary goals!!!

      Cheers Rolf

        Just to be clear, I'm not trying to say Perl shouldn't be/isn't logical... I'm just pointing out some of the logical concepts that come from English where they're involved.

        Also, I tend to think that push having no default to $_ behavior makes sense, partly because it's a binary operator. Since it takes two objects, neither of which is necessarily a scalar, it seems that the sanest way of handling it, in a way that will require the least documentation to understand, is to insist on explicit arguments.

        for(split(" ","tsuJ rehtonA lreP rekcaH")){print reverse . " "}print "\b.\n";