I like @xwu enum IndexOffset
solution, as it's fully descriptive even though slightly verbose. I think having the "magical rule" for negative Int
s mean "backwards from the end", while common, is not that good.
Though I also share the worry of @Ben_Cohen that a subscript
shouldn't hide linear costs. I think that a label on it might not be enough to describe the difference... but at this point, if we require functions, then string[.start(3) ..< .end(2)]
is not that different from string.dropFirst(3).dropLast(2)
, which doesn't have any of the issues listed above.
I like the idea of having a single range, but at this point I wonder if it's a good idea