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:31
Re: [PATCH] Remove implicit split to @_
Message ID:
On Fri, Jul 10, 2009 at 7:49 AM, Michael G Schwern<> wrote:
> Yitzchak Scott-Thoennes wrote:


>> I'm not completely satisfied that "fixing" scalar context is the right
>> thing to do; just like with sort, where there are several "right" scalar
>> context behaviors.
> sort() is a different story.  It always (and I'm sure someone can do some
> trick to make this not true) returns the same number of elements as you put
> in.  So using it in scalar context is a no-op.  Thus making sort in scalar
> context do something else, like the first element, has some merit.

Worth to note that reverse() should behave in the same way as sort to
make it consistent. However, these are the only functions (afair) that
work with lists and don't affect number of elements. May it even is
not important what they do in scalar context unless the following is

my $min = sort @a;
my $max = reverse sort @a;

But I don't care much. Considering Want's ability to count number of
elements on the lhs, it's possible to optimize `my ($m) = [reverse]
sort @a;`

Best regards, Ruslan.

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