kotlin-codepoints
kotlin-codepoints copied to clipboard
[API design] Remove ability to operate on parts of a `CharSequence` via `startIndex` and `endIndex`?
I've been going back and forth on whether to include functions that support a start and end index to only operate on part of a CharSequence. I've landed on not including/removing such functionality.
Reasons for this are:
- It keeps the API surface small(er).
-
CharSequence.codePointAt()can be used without special handling at the end of a partial sequence. - For a caller it's easy enough to use
CharSequence.subSequence(). - Most Java and Kotlin APIs don't support providing a start and end index either, e.g.
CharSequence.forEach()
For feature parity with Java's String.codePointCount(int, int) our CharSequence.codePointCount() will be an exception and continue to support a start and end index.
Before changing CharSequence.codePointIterator(Int, Int) to remove the parameters, I'd like to hear arguments from people who wish for the library to keep supporting operations with a start and end index.