On 2009-Mar-26, at 10:50 pm, Patrick R. Michaud wrote:
But what to do with something like C< 3 cmp '3' >, or any infix:<cmp> where the operands are of differing types? Do we constrain C<cmp> to only work on similarly-typed operands (in which case my sort above would fail), or am I overlooking something obvious?

Failing makes sense to me (you can't compare apples to oranges, at least not without explicitly saying you want compare them only as coerced to general Fruit types). The other way I can think of that might be useful practically is to compare first by type, then by value; but that should probably be a different operation.

say sort { $^a.WHAT leg $^b.WHAT || $^a cmp $^b }, "a", 1, "b", 2 , "c", 3, "d", 4;


Reply via email to