3 ms·
For number literal separators, I'd suggest using underscore rather than apostrophe. Ada, C#, D, Haskell, Java, Kotlin, OCaml, Perl, Python, PHP, Ruby, Go, Rust,
by kibwen 4y ago
For number literal separators, I'd suggest using underscore rather than apostrophe. Ada, C#, D, Haskell, Java, Kotlin, OCaml, Perl, Python, PHP, Ruby, Go, Rust, Julia, and Swift all use the underscore. C++ wanted to use the underscore, but was forced to use the apostrophe because of user-defined literals.
- AlbertoGP 4y agoYes, I meant implementing it as specified for C23 which was done for compatibility with C++, although I do prefer the underscores. Maybe that’s a better idea, implement it with underscores in Cedro as it does not need C++ compatibility. Edit: alright, it works. I also extended the parser to accept the apostrophe as part of number tokens. The only thing it does is to remove the underscores when writing. I might need another command line option to specify whether the output should be C23: 1_234_567 → 1'234'567 or pre-C23: 1_234_567 → 1234567 1'234'567 → 1234567