Liste des Groupes | Revenir à cl c |
On 17/06/2024 01:48, Keith Thompson wrote:[...]
For binary,
the compaction is irrelevant and indeed counter-productive - binary
literals became a lot more practical with the introduction of digit
separators. (For standard C, these are from C23, but for C++ they came
in C++14, and compilers have supported them as extensions in C.)
Octal>
string literals 0"012 345 670" *might* be worth considering.
Most situations where octal could be useful died out many decades ago
- it is vastly more likely that "012" is intended to mean 12 than 10.
No serious programming language supports a leading 0 as an indication
of octal unless they are forced to do so by backwards compatibility,
and many that used to support them have dropped them.
Having /some/ way to write octal can be helpful to old *nix
programmers who prefer 046 to "S_IRUSR | S_IWUSR | S_IRGRP" in their
chmod calls. (And to be fair, the constant names made in ancient
history with short identifier length limits are pretty ugly.) But it
is not something to be encouraged, and I think there is no simple
syntax that is obviously octal, and not easily mistaken for something
else.
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3193.htm>>
proposes a new "0o123" syntax for octal constants; if that's adopted,
I propose allowing 0o"..." and *not" 0"...". I'm not sure whether
to suggest hex only, or doing hex, octal, and binary for the sake
of completeness.
Binary support is useless, and octal support would be worse than
useless - even using an 0o rather than 0 prefix. Completeness is not
a justification for repeating old mistakes or complicating a good idea
with features that will never be used.
What I'm trying to design here is a more straightforward way to>
represent raw (unsigned char[]) data in C code, largely but not
exclusively for use by #embed.
Personally, I'd see it as useful when /not/ using #embed. I really do
not think programmers will care what format #embed uses. I don't
share your concerns about efficiency of implementation, or that
programmers need to know when it is efficient or not. In almost all
circumstances, C programmers never see or need to think about a
separation between a C preprocessor and a post-processed C compiler -
they are seen as a single entity, and can use whatever format is
convenient between them. And once you ignore the implementation
details, which are an SEP, the way #embed is defined is better than a
definition using these new hex blob strings.
Les messages affichés proviennent d'usenet.