parseInt and implicit octal constants
Allen.Wirfs-Brock at microsoft.com
Fri Feb 20 12:14:43 PST 2009
When radix is 0 or undefined and the string's number begins with a 0 digit not followed by an x or X, then the implementation may, at its discretion, interpret the number either as being octal or as being decimal. Implementations are encouraged to interpret numbers in this case as being decimal.
This is item 3.10 in the JScript Deviations document and my notes from when we reviewed the deviations document for
ES3.1 changes says we decided to disallow the octal interpretation in ES3.1. However that change has never been made in the ES3.1 draft.
Does anyone remember if there was a subsequent explicit decision to keep the ES3 status quo or is this just an editing oversight?
Note that IE, FF, and Safari all interpret leading 0 strings as octal while Opera does not. So, arguably ,the de facto standard is to support such octal strings.
The argument for removing the option and mandating either one of the alternatives is improved interoperability across all browsers over the long term.
The argument for disallowing such implicit octal strings is that they are an error hazard.
The argument of requiring support of implicit octal strings is that it is the de facto standard of the web and that disallowing them may break existing webapps.
The cop-out is to just leave it as it is.
The safe decision is to mandate the current de facto standard.
The brave (ie, risky) decision for a better long term language is to disallow octal.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Es-discuss