Fabulous Adventures In Coding
Eric Lippert is a principal developer on the C# compiler team. Learn more about Eric.
octal. Octal causes bugs. I hate bugs, particularly stupid "gotcha" bugs.
C programmers do things like
realizing that this does not assign the number 703, but rather 7 x 64 + 3 = 451.
worse, foolish JScript programmers do things like
realizing that the former is a decimal literal but the latter is an octal
in JScript it really is the case that if a literal begins with 0, consists of only
digits and contains an 8 or a 9 then it is decimal but if it contains no 8 or 9 then
it is octal! The first version of the JScript lexer did not implement those
rules, but eventually we changed it to be compatible with Netscape's implementation.
is in keeping with the design principle that I mentioned earlier, namely "Got a
problem? Muddle on through!" However, since this problem can be caught at
compile time, I think that the decision to make illegal octal literals into decimals
was a poor one.
just a mess. Octal literals and escape sequences have been removed from the ECMAScript
specification, though of course they live on in actual implementations for backwards
is why I added code to JScript .NET so that any use of an integer decimal or octal
literal that begins with zero yields a compiler warning, with one exception.
= 0; does
not produce a warning!