Re:Tell HN: C Experts Panel – Ask us anything about C
by OnACoffeeBreak on Tuesday April 14, 2020 @10:09AM
(#22866156)
I know that we're not voting, but I miss a binary literal very much. I would also like a literal digit separator to improve readability. Verilog Hardware Description Language does that with an underscore [1]. For example, 0xad_beef to improve readability of a hex literal, and 0b011_1010 to improve readability of a binary literal.
Re:Tell HN: C Experts Panel – Ask us anything about C
by jfkebwjsbx on Tuesday April 14, 2020 @10:16AM
(#22866246)
If they pick this up, they will likely use C++'s syntax/rules.
Re:Tell HN: C Experts Panel – Ask us anything about C
by nickysielicki on Tuesday April 14, 2020 @10:04AM
(#22866098)
In the same vein, I really like being able to use underscores in binary and hex literals to denote subfields in hardware registers.
0xDEADB_EEF
0b1_010_110111001001
etc.
Re:Tell HN: C Experts Panel – Ask us anything about C
by jhallenworld on Tuesday April 14, 2020 @10:08AM
(#22866143)
Should take Verilog binary construction syntax, like { 12'd12, 16'hffee, 3'b101 } (or something similar that would fit with C's syntax).
Re:Tell HN: C Experts Panel – Ask us anything about C
by dirtydroog on Tuesday April 14, 2020 @11:30AM
(#22867180)
Maybe not.
Re:Tell HN: C Experts Panel – Ask us anything about C
by jhallenworld on Tuesday April 14, 2020 @03:53PM
(#22870661)
Why not? If you have to combine bit fields now, it's a mess of shifting and masking.
Re:Tell HN: C Experts Panel – Ask us anything about C
by pascal_cuoq on Tuesday April 14, 2020 @10:08AM
(#22866145)
Many C compilers offer, as an extension, the very binary constant notation that you miss, as anyone who has worked on the front-end of a C static analyzer would tell you.
Re:Tell HN: C Experts Panel – Ask us anything about C
by ux on Tuesday April 14, 2020 @10:11AM
(#22866175)
Yes I'm aware. But we can agree it would be welcome in the standard, isn't it?
Re:Tell HN: C Experts Panel – Ask us anything about C
by pascal_cuoq on Tuesday April 14, 2020 @10:44AM
(#22866601)
Yes, if only so that we (as a category) do not have to discover it exists when already facing C programs that use it.
Re:Tell HN: C Experts Panel – Ask us anything about C
by r12477 on Tuesday April 14, 2020 @06:50PM
(#22872431)
For binary constant notation, I have incorporated the following macro into my projects: https://gist.github.com/61131/009961b781f387ed1474ffaf19e375...
Re:Tell HN: C Experts Panel – Ask us anything about C
by eqvinox on Tuesday April 14, 2020 @10:15AM
(#22866231)
I haven't read most of that rant, but a thread-local setlocale() would be a godsend. Not sure if that's ISO C or POSIX though.
Re:Tell HN: C Experts Panel – Ask us anything about C
by wahern on Tuesday April 14, 2020 @06:02PM
(#22872040)
POSIX has added _l variants taking a locale_t argument to all the relevant string functions. I can see how per-thread state would be convenient, but it's not a comprehensive solution. With the _l variants you can write your own wrappers that pass a per-thread locale_t object.
Re:Tell HN: C Experts Panel – Ask us anything about C
by EdSchouten on Thursday April 23, 2020 @04:07PM
(#22960595)
That's uselocale().
Some hints on what I'm referring to can be found here: https://github.com/mpv-player/mpv/commit/1e70e82baa9193f6f02...
Unrelated, but I also miss a binary constant notation (such as 0b10101)