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.
--
My Dad used to say 'always fight fire with fire', which is probably why
he got thrown out of the fire brigade.
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.
--
My Dad used to say 'always fight fire with fire', which is probably why
he got thrown out of the fire brigade.