On Dec 21, 2013, at 12:00 AM, Moritz Lenz <mor...@faui2k3.org> wrote:

> On 12/20/2013 04:52 AM, Richard Hainsworth wrote:
>> OK x not xx.
>> The doubling of operators is confusing.
> OTOH having a single operator which two different meanings is also confusing 
> (and very un-perlish).

Sometimes, yeah.  On a related note, I sometimes wish that qw«= < >» and the 
like were general-purpose comparison operators rather than explicitly numeric 
comparators.  I understand why Perl uses them in the way that it does (mainly, 
it’s a legacy thing from Perl 5, when there weren’t any data types and the 
distinction between “number” and “string” had to be built into the operator); 
but it takes a lot of getting used to, and there are times that I wish that the 
language would use some argument-based magic to let me sort arbitrary objects 
using “<” instead of “before”.  

If it wasn’t for the need for backward compatibility, I’d want something like 
the following:

  $a < $b :as(Num) #[coerce $a and $b to Num.  Same as “$a < $b” now.]
  $a < $b :as(Str) #[coerce $a and $b to Str.  Same as “$a lt $b” now.]
  $a < $b :as(*) #[don’t coerce anything.  Same as “$a before $b” now.]
  $a < $b #[coerce $b to whatever type $a is for the comparison.  No simple 
equivalent now.]

That strikes me as better “principle of least surprise” than the current 
approach.  Alas, I suspect that the ship has long since sailed on this idea.  

Reply via email to