On 16 Jul 2005 12:22:31 -0000, David Formosa (aka ? the Platypus) <[EMAIL PROTECTED]> wrote: > On Sat, 16 Jul 2005 12:14:24 +0800, Autrijus Tang > <[EMAIL PROTECTED]> wrote: > > [...] > > > On Sat, Jul 16, 2005 at 12:24:21AM +0300, Yuval Kogman wrote: > >> > There is a new generic comparison operator known as ~~. > >>=20 > >> ~~ is just Eq, there is also Ord > > > > Hmm, <~ and ~> for generic comparators? ;) > > Unfortunitly we have ~< and ~> meaning shift string left and shift > right.
Well, those can always move aside for more important operators. In fact, there's something to be said for being like Prolog and avoiding all arrow-looking things that aren't actually arrows, so: =< >= less-equal, greater-equal ~< >~ string shift left, string shift right ... But, there's also something to be said against it, especially for those two. ~ is acting as a kind of meta-prefix, so putting it on the end is silly. =< Reads like equal or less than, which is weird. Anyway, what I really meant to say is that for higher level code, you see generic comparisons a lot more than you see numeric or string comparisons. But for scripting code, the opposite is true. Last year, Larry used the operator "equal" for generic equality (I personally would have picked "equals"). But I think that's a little awkward if it is to be used often. I'm going to have some coffee mugs thrown at me for saying this, but perhaps: Generic String Numeric Identity +-----------+---------------+----------------+---------------+ Equality | == | =~= | =+= | =:= | +-----------+---------------+----------------+---------------+ Comparison | > < >= <= | ~> ~< ~>= ~<= | +> <+ +<= +>= | $a.id < $b.id | +-----------+---------------+----------------+---------------+ Another possibility is to embrace the concept that two objects with reference semantics are not equal unless they are identical, and also say that 3 =:= "3" (because they behave the same in every way). Then we could keep our old way of life with numeric == and string eq, and use <: and :> for generic comparison (by analog of =:= for generic equality). But if we want to do that, then we'd have to define <: and :> in terms of .id or some other thing that's not overloadable except for value types. For the record, this sounds great to me, because I use value types for everything. But I expect some people would be pretty irritated by that. All in all, generic equality and comparison is something that Perl 5 did really poorly. Some people overloaded eq, some overloaded ==, some wrote a ->equal method, and there was no way to shift between the different paradigms smoothly. This is one of the times where we have to choose for them. Luke