Front page | perl.perl5.porters |
Postings from October 2011
Re: $[ proposal
Thread Previous
|
Thread Next
From:
Michael G Schwern
Date:
October 30, 2011 21:06
Subject:
Re: $[ proposal
Message ID:
4EAE1EC3.9010301@pobox.com
On 2011.10.30 1:33 PM, Father Chrysostomos wrote:
> Have you seen Jesse’s new policy? Let me quote the relevant part:
>
>> It's time for us to start extracting parts of what has traditionally
>> been considered the "language" part of Perl 5 into CPANable modules.
>> To do this successfully, it is imperative that _nothing_ appear out
>> of the ordinary to code that expects to use those features. If code
>> doesn't declare use v5.16, it should still get the 5.14ish environ-
>> ment it would expect.
If $[ were a feature we wanted to keep, and if there were any concern that
real code uses it, then Jesse's policy would apply. Your patch is technically
brilliant, and I personally very much appreciate the effort that must have
gone into it, but this is about improving the language.
$[ is a "feature" that's been on the chopping block for a long time. Its
behavior has already changed twice (global to file scoped in 5.0 and lexically
scoped in 5.10), a lot of old code that relied on it probably already doesn't
work.
Furthermore, it's presence is actively harmful to Perl programmers. Why?
It's more likely to be confused with $] or used in defense than to be used as
intended.
Google Code Search finds 95 instances of '$[ = 1'. [1] Only 5 are in pm
files (4 are joke modules). [2] 32 are in tests. [3] 48 are in .pl files.
[4] It can be removed and hardly anyone would blink.
There are 96 instances of $[ being used where they meant $]. [5] Once $[ is
removed we can put in a warning upon seeing it and this code can be fixed. I
never remember which is which either and always have to check.
There are 218 instances of $[ being used defensively [6]. That is, people
wrote extra code because they couldn't be sure were arrays started. It might
be nice to leave $[ in as a read-only 0 to let this code work... but they
could also just replace the $[ with 0.
There are hardly any legit users and it is at least THREE TIMES more likely
that $[ will be used either INCORRECTLY or DEFENSIVELY. That is not a feature
worth writing, maintaining, debugging and documenting a bunch of extra code to
preserve. That is a land mine to be disarmed and removed.
[1]
http://www.google.com/codesearch#search/&q=%5C$%5C%5B%5C%20=%5C%20%20lang:perl&p=15&sq=&type=cs
[2]
http://www.google.com/codesearch#search/&q=%5C$%5C%5B%5C%20=%5C%201%20lang:%5Eperl$%20file:.pm$&type=cs
[3]
http://www.google.com/codesearch#search/&q=%5C$%5C%5B%5C%20=%5C%201%20lang:%5Eperl$%20file:.t$&p=3&type=cs
[4]
http://www.google.com/codesearch#search/&q=%5C$%5C%5B%5C%20=%5C%201%20lang:%5Eperl$%20file:.pl$&p=6&type=cs
[5]
http://www.google.com/codesearch#search/&q=%5C$%5C%5B%5C%20%5B%3C%3E=%5D%2B%5C%205%5C.%20lang:%5Eperl$&p=9&type=cs
[6]
http://www.google.com/codesearch#search/&q=%5C$%5C%5B%5C%20%5B%5E15%3C%3E=%5D%20lang:%5Eperl$&p=27&sq=&type=cs
--
Reality is that which, when you stop believing in it, doesn't go away.
-- Phillip K. Dick
Thread Previous
|
Thread Next