`RangeExpression`s with exclusive lower bounds

This has come up before, but you’re right it’s hard to find on this list likely because it was so long ago.

One major barrier is that the obvious spellings (and almost all variations on them) are not valid in Swift, because operators in Swift that contain . must begin with .

Changing the rules to allow the desired operators is one approach but gets bogged down because in Swift any character must be used either for operators or for identifiers, and the divide among them is currently rather haphazard and in need of refinement. It’s a much larger topic to divide emoji and math symbols rationally among operator and identifier characters.

The alternative approach is to make these range operators a one-off exception, but that does complicate the language.

The question is whether such a complication can be justified to fill out the lesser used range types—they do have some role but, to be honest, several years after proposing to add them, I don’t miss them.

All of this is to say that there’s no point in bikeshedding the spelling here. What would progress the topic is coming up with compelling use cases. It’s not enough that it would “fill out” the ranges—what scenarios have you encountered where using such a range instead of the alternatives (manually comparing end points, for example) demonstrate that such ranges would make the language dramatically more expressive?

1 Like