Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-9032] Add ability to create ‘character' literals to compiler. #51535

Open
johnno1962 opened this issue Oct 18, 2018 · 1 comment
Open
Assignees
Labels
compiler The Swift compiler in itself feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal

Comments

@johnno1962
Copy link
Contributor

Previous ID SR-9032
Radar None
Original Reporter @johnno1962
Type New Feature
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels New Feature, LanguageFeatureRequest
Assignee @johnno1962
Priority Medium

md5: 82dd26a9f4af318193363fdfc65d9a9d

Issue Description:

It is sometimes useful to be able to express the ascii value of a character more conveniently than the existing UInt8(ascii: “a”) and now that the syntax for raw strings has taken a different direction it is suggested this be simply ‘a’ as it is in many other languages. These would be Character literals in the Swift sense, able to express any UNICODE extended grapheme cluster but if the cluster contains only a single code point it should be possible to express Swift’s integer types using this literal syntax. As examples:

let a: Int8 = ‘a’
let newline: Int8 = ‘\n’

@belkadan
Copy link
Contributor

I know there's a long thread about this but I feel it's worth pointing out that we have this: it's UnicodeScalar.

let x: UnicodeScalar = "x"

The proposal here would be extending that to work for plain integers if the value is known to fit in the integer, I guess.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal and removed new feature labels Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants