develooper Front page | perl.perl5.porters | Postings from January 2022

Re: ban empty sorts for 5.36 to free the colon?

Thread Previous | Thread Next
H.Merijn Brand
January 17, 2022 13:44
Re: ban empty sorts for 5.36 to free the colon?
Message ID:
On Mon, 17 Jan 2022 11:34:40 +0000, Dave Mitchell <> wrote:

> I propose that a sort with no physical arguments should be made
> a compile-time error for 5.36:
>     @a = sort; # currently equivalent to @a = (); would become compile error
>     @empty = (); @a = sort @empty # unaffected
> I suspect that this usage is exceedingly rare in real code, and if present
> represents a thinko.
> The advantage of making it a compile-time error (and thus flushing out any
> remaining uses of it) is that it then allows for the possibility at some
> future time of adding an attribute-like syntax to sort.
> At the moment, in:
>     @a = $cond ? sort :  ....;
> the colon is interpreted as part of the ternary conditional operator. I
> would like to open up the possibility in the future of the colon being
> interpreted instead as part of the sort syntax, introducing some sort of
> attribute. For example (hypothetically):
>     sort :num 4,3,5;
> says to sort numerically. Or perhaps to introduce an inline sub:
>     sort :sub ($x,$y) { $x <= $y  } 4,3,5
> or whatever.
> The important thing is that I don't want to start a long discussion (yet)
> about HOW the new syntax could be used; I just want to get quick agreement
> that by banning empty sorts ASAP we free up the syntax space for use in a
> few releases' time.

I do not see any negative impact of this proposal, so I support it

H.Merijn Brand   Perl Monger
using perl5.00307 .. 5.33        porting perl5 on HP-UX, AIX, and Linux

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