On Mon, 17 Jan 2022 11:34:40 +0000, Dave Mitchell <davem@iabyn.com> 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 https://tux.nl Perl Monger http://amsterdam.pm.org/ using perl5.00307 .. 5.33 porting perl5 on HP-UX, AIX, and Linux https://tux.nl/email.html http://qa.perl.org https://www.test-smoke.orgThread Previous | Thread Next