SE-0243: Codepoint and Character Literals

I agree with this feedback, and it is the main thrust of my review comment about this revised proposal:

In general, I thought that the proposal was acceptable in its previous incarnation, but removing conformances due to ABI limitations and then making them opt-in is a very strange way of vending a feature. It's not discoverable, and it's certainly not convenient.

Instead of trying to push ahead with the minimum possible modification to the design, we need to revisit this design more comprehensively because the pros and cons have changed dramatically.

(To make it explicit: The previous pro of the highest possible convenience in writing let x: Int = 'a' is very much tempered when one must write a conformance. We also introduce a new con that we are encouraging people to conform a type they don't own to a protocol they don't own, which is absolutely contrary to what we tell people otherwise.)

By contrast, init(ascii:) seems very straightforward, and if we care indeed about convenience for initializing arrays of integers in this way, we can vend also a similar initializer on extension Array where Element: FixedWidthInteger.

If compile-time checking is required, there is no reason why the compiler cannot be made to have special knowledge of these init(ascii:) methods to make this work until such time as the constexpr-like features mature and supersede that magic.

7 Likes