[Accepted with modifications] SE-0445: Improving String.Index’s printed descriptions

Hi all,

The review of SE-0445: Improving String.Index's printed descriptions concluded on September 30, 2024. The language steering group has decided that the proposal should be accepted with modifications.

Feedback was generally positive, with some clarifications provided regarding what the index type represents and what it does not track. A central point of discussion was whether the conformance in question ought to be to CustomDebugStringConvertible rather than (and not in addition to) CustomStringConvertible. This group was asked to weigh in on what these protocols are "for."

There was agreement among the group with the simple explanation that debugDescription is the most appropriate API to provide a textual representation that is specifically "for" debugging.

While it's true that, where a standard library type implements both description and debugDescription, the latter often adds or removes punctuation so as to be more suitable for structured display, it's not the formatting details which alone account for the difference between the two APIs. Instead, the group was inclined to agree with reviewer feedback that conformance to CustomDebugStringConvertible conveys the intended use of the corresponding textual representation—namely, that it is oriented specifically towards debugging, and no attempt should be made to parse, convert, or otherwise manipulate the output.

By contrast, a value's description could be suitable for more general use. In this case, for example, it's conceivable that one could have a textual representation for string indices that'd be useful for someone learning about Unicode and who's totally unfamiliar with the String.Index type or even Swift at all. The representation proposed here is explicitly not that.

For this reason, the language steering group would adopt the proposal with the modification that conformance would be to CustomDebugStringConvertible instead.

Thank you, as always, to all participants in this review process for helping to make Swift a better language.

Xiaodi Wu
Review Manager

7 Likes