develooper Front page | perl.perl5.porters | Postings from September 2013

Re: unstable mergesort?

Thread Previous | Thread Next
From:
Aaron Crane
Date:
September 11, 2013 22:10
Subject:
Re: unstable mergesort?
Message ID:
CACmk_tvMtLsPADY1C0=78jQ0KgNxDWEmqrwhNsyr=uDepF5AHQ@mail.gmail.com
Father Chrysostomos <sprout@cpan.org> wrote:
> We already document that stability is not guaranteed.  If this will
> speed things up, I suggest making it the default.
>
> We also already have ‘use sort "stable"’, which I thought actually did
> something, but what you have written suggests it does not.

As it happens, I was thinking about this a few days ago, before this
discussion kicked off.  I'm somewhat of the view that stability is a
better "don't make me think" default, in the sense that if you don't
need it but get it anyway, your code works correctly; whereas if you
do need it but don't get it, your code doesn't.  (This may be a
problem with the idea of changing the default; a CPAN smoke would
presumably give us an idea of the size of that problem.)  For that
reason, I was on the verge of (but sadly didn't get round to)
proposing a doc patch saying that we guarantee a stable sort except
when you explicitly ask for an unstable one.

Even if the consensus is in favour of switching the default to
(faster) instability, I think we should document what the default is.
Currently we have the situation that everyone gets a stable sort
(unless they ask for an unstable one) but the default might change out
from under you, so if you need stability, you have to ask for it
anyway.  It would be annoying to replicate that problem in the other
direction.

-- 
Aaron Crane ** http://aaroncrane.co.uk/

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