Character class ranges in grapheme-semantic regexes deserves focused discussion. Comparison is linguistically meaningless for grapheme clusters. Then again, so is just about any interpretation on Character
, but that doesn't mean that Swift cannot supply common-sense semantics. We have options as to how we want to define this, and a sensible starting point would be <
on Character
itself, noting that Range<Character>
is uncountable. For the literal, options include warning or erroring out
This isn't anything new, and we will have plenty of similar concerns surrounding our handling of e.g. degenerate grapheme clusters.
Right, whether a regex is scalar-semantic or grapheme-semantic may not be know at declaration site, so we may have to invent a way of carrying this information forwards if we want to provide different diagnostics for each.
Also note that many common ranges can be otherwise expressed as a combination of known character classes, so there's some opportunities for nice fixits.