Syntactic sugar: char literal that automatically converts the unicode value to a u32
See original GitHub issueFeature Request
Overview
Using a full-blown string in WASM is overkill if you just want to compare a single character to another value. A char literal would help.
Impact
Medium. It’s very convenient - without it one would have to resort to manually inserting unicode values.
Due Date
How hard is it to implement? I don’t know the Walt compiler stack. But if it’s in JavaScript, then it should boil down to identifying a single-character, calling codePointAt(0)
to get the integer value, and ensuring it is assigned to an i32
, no?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:24 (9 by maintainers)
Top Results From Across the Web
Discussion: Strings · Issue #104 · ballercat/walt · GitHub
@JobLeonard JobLeonard mentioned this issue on Mar 10, 2018. Syntactic sugar: char literal that automatically converts the unicode value to a u32 #103....
Read more >Language specification — The Co programming language - rsms
Character literals. Represents a character constant; an integer value identifying a Unicode code point. Within the quotes, any character may appear except ...
Read more >WebGPU Shading Language - Orillusion
The ConversionRank function expresses the preference and feasibility of automatically converting a value of one type (Src) to another type ...
Read more >Overview | Odin Programming Language
In Odin, if a number constant can be represented by a type without precision loss, it will automatically convert to that type. Constant...
Read more >The Rust Reference
A character literal is a single Unicode character enclosed within two U+0027 (single-quote) characters, with the exception of U+0027 itself, which must be ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s maybe an implementation detail but it’s simpler IMO to add a rule in the type inference.
According to the definition above,
The
type
is independent of what’s on the right side, so that would require a condition in the parser and you wouldn’t be able to catch the error in:Oh right, I forgot that Walt has static type support 😛