3 ms·
A potentially better syntax would be 0o100, e.g.
by dnautics 8y ago
A potentially better syntax would be 0o100, e.g.
- pjc50 8y ago> 0o100 This is some IOCCC level stuff, not distinguishable in all fonts. I'd rather borrow a couple of ideas from Verilog, including the cosmetic underscore and the ability to represent binary, e.g. 8'b0101_1100
- jandrese 8y agoYou could even support binary that way: 0b10101101 If you standardize this the leading zero becomes somewhat unnecessary. But of course it's probably too late for C. You would have to depreciate the old notation for decades before it could be removed.
- kazinator 8y agoDeprecating is as simple as emitting a diagnostic whenever it occurs, rate-limited to once per translation unit, say.
- jandrese 8y agoYes, but it also means fixing all of that old code before you can turn the depreciation into full on removal. It would be interesting to note that such warnings would undoubtedly point out a few errors in existing code where people 0 padded a number they expected to be decimal. Many would be harmless, 00001 for example, but a few could have been causing unintended side effects (incorrect initialization values for example).
- steveklabnik 8y ago(As I mentioned above, Rust does exactly this; 0o for octal, 0b for binary.)