On 2010-07-29 01:39, Jon Lang wrote:
Aaron Sherman wrote:

In smart-match context, "a".."b" includes "aardvark".

No one has yet explained to me why that makes sense. The continued use of
ASCII examples, of course, doesn't help. Does "a" .. "b" include "æther"?
This is where Germans and Swedes, for example, don't agree, but they're all
using the same Latin code blocks.

This is definitely something for the Unicode crowd to look into.  But
whatever solution you come up with, please make it compatible with the
notion that "aardvark".."apple" can be used to match any word in the
dictionary that comes between those two words.

The key issue here is whethere there is a well defined and meaningful ordering of the characters in question. We keep discussing the nice examples, but how about "apple" .. "ส้ม"?

I don't know enough about Unicode to suggest how to solve this. All I can say is that my example above should never return a valid Range object unless there is a way I can specify my own ordering and I use it.

I've never accepted that the range between two strings of identical length
should include strings of another length. That seems maximally non-intuitive
(well, I suppose you could always return the last 100 words of Hamlet as an
iterable IO object if you really wanted to confuse people), and makes string
and integer ranges far too divergent.

This is why I dislike the notion of the range operator being used to
produce lists: the question of what values you'd get by iterating from
one string value to another is _very_ different from the question of
what string values qualify as being between the two.  The more you use
infix:<..>  to produce lists, the more likely you are to conflate lists
with ranges.

I second the above. Ranges are all about comparing things. $x ~~ $a .. $b means "is $x between $a and $b?". The only broadly accepted comparison of strings is lexicographical comparison. To illustrate the point: wouldn't you find it odd if 2.01 wasn't in between 1.1 and 2.1? Really?

Regards,

Michael.

Reply via email to