Simple operators for character value comparisons. #71749
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Apple,
After a long deliberation on swift-evolution I'd like to propose these operators and initialisers be added to the standard library to improve the ergonomics of working with the integer representation of character values. This has already be explored and benchmarked extensively on this PR to the
swift-syntax
project which was merged some weeks ago. I've tried to pair it down to the absolute minimum so there shouldn't be anything too contentious in what remains. In summary you can compare aUInt8
value to a double quoted single unicode code point string literal for equality, make this comparison in aswitch
. There is also a new initialiser for all integer types from a unicode scalar and finally a new Array initialiser from the unicode scalars in a String.These operators use the existing language to improve the ergonomics of parser code without having to press into service single quotes and make changes to the compiler as has been previously proposed. PR to swift-evolution with the proposal to follow.
Resolves #SR-9032