There is a bunch of historic precedents where we see those precious "reserved for future use" bits and bytes are never used – at first because they are precious, then because it's too late / or due to compatibility or there are better workarounds or etc, then the thing dies :)
It would seem that perhaps life is like black jack, in that it is significantly better to leave one’s potential partially untapped than to “bust”, despite the sometimes bitter taste of reflecting on what might have been. We must just do our best and always appreciate what we have…
This issue actually touches on the ergonomics of many separate parts of what should be a single system.
String
API for ensuring characters are within a certain category or range. This is actually mostly complete with the unicode properties we have, where the original question is largely$0.isASCII && $0.isWholeNumber
.- Round trip application and removal of formatting. This should be something
Formatter
could handle, but it's not a good API for Swift, so a modern solution would be nice here. Something which enables separate "visible" values and "stored" values. - Storage of the "true" value typed by the user, with or without formatting, as sometimes the formatting should be part of that value and sometimes it shouldn't. No great solution here. SwiftUI tries to use
Formatter
for this but fails miserably.
Unfortunately, most of the missing work here is on the Foundation and UI side of things, so I'm not sure there's much Swift itself can do here. But I'm pretty sure there isn't much for String
to do.
2 Likes
This reminded me of a todo I’d been meaning to fix, so: It's 48 bytes minimum now
Though we’ll only make ones that small in mildly unusual cases
4 Likes