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

Re: [PATCH] Remove implicit split to @_

Thread Previous | Thread Next
From:
Ruslan Zakirov
Date:
July 13, 2009 16:31
Subject:
Re: [PATCH] Remove implicit split to @_
Message ID:
589c94400907131631w46503172n7ded94a08442dc89@mail.gmail.com
On Fri, Jul 10, 2009 at 7:49 AM, Michael G Schwern<schwern@pobox.com> wrote:
> Yitzchak Scott-Thoennes wrote:

[snip]

>> 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
optimized:

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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About