question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Syntactic sugar: char literal that automatically converts the unicode value to a u32

See original GitHub issue

Feature 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:24 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
xtuccommented, Mar 12, 2018

It’s maybe an implementation detail but it’s simpler IMO to add a rule in the type inference.

According to the definition above,

assignment -> identifier : type = string | char;

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:

function f(c: char) {}

f("ab")
f("a")
2reactions
JobLeonardcommented, Mar 12, 2018

Oh right, I forgot that Walt has static type support 😛

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found