Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: An Apology for Puncish

by moritz (Cardinal)
on Jan 27, 2009 at 20:36 UTC ( #739335=note: print w/ replies, xml ) Need Help??


in reply to An Apology for Puncish

The "specially named" variables are good case of "huffman coding", ie commonly used constructs should have short names.

To exaggerate a bit: if I wanted to type $INPUT_RECORD_SEPARATOR instead of $/ (or System.out.println instead of say), I'd code in Java instead of Perl.

More to the point: making things practical to use has always been one of Perl's philosophies - and long names simply aren't practical.


Comment on Re: An Apology for Puncish
Select or Download Code
Re^2: An Apology for Puncish
by DStaal (Chaplain) on Jan 27, 2009 at 21:21 UTC

    I'd disagree that these are generally 'commonly used constructs', with the exceptions of $_, $!, and $@. Most of them seem to only be needed once in a blue moon, in fact.

    I agree with your logic otherwise, just not with the specific premise that these are the commonly used values.

      I think it depends on what you mean by "used." Many of them are used in the background constantly. $. and $/ (at least?) are implicit in every file read, for example.

      "Commonly used" depends very much on what programs you write. I write one-liners very often that extract one or two columns of data from somewhere, so I do use $0 very often, probably more often then explicit $_.

      I'm sure that's different if you spend most time on highly engineered OO programs or other areas.

      I think many of these short variable names were chosen to deal with the limits of interpreters on 1960s-ish machines. At that time, some of the principles underlying Huffman encoding were in play.

      Perl just adopted many of these names as part of its mission. That Larry Wall chose to preserve the distinctive nature of this namespace and keep its expansion out of the spaces that would be commonly chosen for user tasks seems to me to be one of the insightful decisions in Perl's design. That it continues with ${^Word} style names is good.

      Be well,
      rir

      Update: very minor language cleanup

      Update: reworked poor sentence: the struck out stuff. You can't expand an ad hoc namespace because you're creating a new one. The underlined text replaces: add most of his other predefined variables into a namespace that ... words are failing me a bit, but he kept the namespace distinctive and

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (14)
As of 2014-09-19 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (135 votes), past polls