Walter Bright wrote:
Stewart Gordon wrote:
Walter Bright wrote:
<snip>
The octal literals are done the way C does them. The reason they are
there are for when translating C code to D code, obscure bugs are not
introduced.
How would making them illegal not achieve this aim?
The only point to making them illegal would be to eventually remove them
completely, which puts us back to \00 meaning something different in D
than in C.
The "Obscure bugs during translation from C" argument presumes that such
errors are more likely than ones such as:
int powersOfTen[] = {
0001, //okay
0010, // error: this is 8, not 10
0100, // error: this is 64, not 100
1000, // okay
};
and what the heck does "\000000\000000000\000\0000" mean?
I doubt there is much extant C code which uses octal. Automated
translations of octal literals can be done accurately, and you're even
supplying the 'htod' converter!
Note that C# doesn't have octal literals, but does include \0. So
there's a precedent for dropping them. This also means that right now,
converting code from C# to D can also introduce obscure bugs. I'd argue
that that's a scenario that is at least as likely as bugs from C.
I think the argument for octal is very, very weak.