On 2008-Dec-15, at 4:18 pm, Jon Lang wrote:
If you've got a list of Pairs, you use a sorting algorithm that's designed for sorting Pairs (which probably sorts by key first, then uses the values to break ties).

Agreed.

If you've got a list that has a mixture of Pairs and non-Pairs, I think that the sorting algorithm should complain: it's clearly a case of being asked to compare apples and oranges.

If there's no cmp(Pair, Other::Thing) defined, then it would fall back to string-comparison, which seems fair to me. But complaining isn't unreasonable either, since it's easy to coerce stuff to strings if that's what you want.

I guess you could force complaining with: infix<cmp>:(Any, Any) = { die "Apples and oranges!" }

When are you going to be asked to stringify or numify a Pair? Actual use-cases, please. Personally, I can't think of any.

say $pair;

I can't really think of a great example where you'd want to numify a pair, but I would expect printing one to produce something like "a => 23" (especially since that's what a one-element hash would print, right?).


-David

Reply via email to