develooper Front page | perl.perl5.porters | Postings from July 2009

Re: [PATCH] Remove implicit split to @_

Thread Previous | Thread Next
Ruslan Zakirov
July 13, 2009 16:52
Re: [PATCH] Remove implicit split to @_
Message ID:
On Fri, Jul 10, 2009 at 7:23 PM, Ben Morrow<> wrote:
> Quoth (Peter Scott):
>> On Thu, 09 Jul 2009 21:28:14 -0700, Chip Salzenberg wrote:
>> > This is an amusing discussion.
>> >
>> > The only problem that I observe with scalar split writing to @_
>> > implicitly is that it's an easy thing to do by accident and is almost
>> > never useful. Therefore, removing it seems a public service.
>> >
>> > I favor simply making it a compile-time error to use split in scalar
>> > context.  No problem with silently changing semantics and no more
>> > surprising behavior.  Everybody's happy.  (right?)
>> I don't get it.  The docs say that scalar split returns the number of
>> elements.  That's useful and convenient, and more intuitive than some of
>> the alternative gyrations that have been suggested.  No one cares about it
>> shoving the contents in @_ or wants that to continue, especially since it
>> results in a warning.  So why can't we make it return the number of
>> elements without either populating @_ or generating a warning?
> One good reason might be: someone who writes something on 5.12, and
> doesn't know the history of scalar split, will get a nasty surprise when
> they run that code on <=5.10.

perldoc bytes; # doesn't mention that it doesn't work in 5.6

Another way around that may satisfy all people except implementer :) :

* code without `no (strict|warnings) 'scalar split';` or `use
5.######` (where change is implemented) issue die or warning that

your code uses split in scalar context. In perl 5.x.y and earlier that
causes @_ to be overwritten, either don't use it or define minimal
perl version required using 'use 5.######'.

That's it.

Best regards, Ruslan.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About