develooper Front page | perl.perl5.porters | Postings from June 2004

Re: sort in scalar context, but broken due to inexperience.

From:
david nicol
Date:
June 9, 2004 17:11
Subject:
Re: sort in scalar context, but broken due to inexperience.
Message ID:
1086826211.1014.60.camel@plaza.davidnicol.com

Phooey.  I had thought there was a consensus in favor of the
sortedness thing.

The patch, being mostly cut-and-paste, doesn't add all that much
new code. Thanks for the advice about return convention

The sorting_av flag appears to be part of the sort-in-place feature.

On Tue, 2004-06-08 at 09:59, Nick Ing-Simmons wrote: 
> This looks like quite a big change for a return value which we seem
> unable to reach consensus on. 
> (I would still like sort in scalar context to return min or max value
>  - don't care which because one can change cmp function to get the other.)
> 
> What can one use your sortedness value for?

I'm not too clear on that.  Initial data analysis I suppose.  Who was
asking for the feature?  Let's hear their justification for it.  Archive
search indicates that Merlyn said that is what should happen.

http://groups.google.com/groups?selm=004501c42895%242d13d890%244722000a%40omarests2

> From: Randal L. Schwartz [mailto:merlyn@stonehenge.com]
> Jay> Understanding that, now I'm wondering why sort() returns undef in
> Jay> scalar context. Shouldn't sort in scalar context return the
> Jay> number of elements sorted?
> 
> No.  It's not documented that way.  It returns undef now.  Maybe
> in a future Perl it will return "percentage sortedness" if there's
> a fast way to calculate that.


On Wed, 2004-06-09 at 05:23, hv@crypt.org wrote:
> Dave Mitchell <davem@iabyn.com> wrote:
> :
> :I thought that the concensus (such as it is) in a scalar context was that a
> :concensus couldn't be reached on what it was supposed to return, and that
> :therefore it should be left as is, with the warning?
> 
> That's certainly the consensus that I have reached.

-- 
david nicol
 "cat and buttered toast" 




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