xwu
(Xiaodi Wu)
May 2, 2020, 6:52pm
3
There have been extensive discussions on this topic which you may be interested to read.
If, after reviewing these links, you feel like there's a new direction or perspective to be had on the topic, then by all means please do share! In that case, it can be helpful for the community if you'd write a short synopsis of what you learn from these readings so that we're not starting back at square one.
In C, 'a', is a char literal, equivalent to 97. Swift has no such equivalent, requiring awkward spellings like ("a" as Unicode.Scalar).value, which may or may not need additional casts to convert it to the right integer type. Or worse, spelling out the values in hex or decimal directly. This harms readability of code.
static char const hexcodes[16] =
{
'0', '1', '2', '3', '4' ,'5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f'
};
let hexcodes:[UInt8] =
[48, 49, 50, 51, 52, 53ā¦
Hi Swift Community,
The review of SE-0243: Codepoint and Character Literals begins now and runs through March 12, 2019.
Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to me as the review manager via email or direct message on the forums. If you send me email, please put "SE-0243" somewhere in the subject line.
What goes into a review of a proposal?
The goal oā¦
In light of the core team's decision on SE-0243 , I'd like to kick off a pitch for single-quoted literals based on the feedback given.
It's the product of multiple people's work but, while we figure out who's signing on to it, here it is so that we can relaunch the conversation. I'll take the blame for all typos and other errors:
Unicode scalar literals
Introduction
Swift's String type accommodates Unicode by default and models a Collection of extended grapheme clusters, which in Swift are iā¦
1 Like