On Mon, Feb 23, 2009 at 10:13 AM, Garrett Smith <[email protected]> wrote: > On Sun, Feb 22, 2009 at 9:30 AM, Allen Wirfs-Brock > <[email protected]> wrote: >> David-Sarah Hopwood wrote: >>> >>>Herman Venter wrote: > > >> Finally, there is another approach to resolving this issue. Define a new >> global function, parseInteger, that does the "right thing" and relegate >> parseInt to Annex B. >> > > That is a good idea, but I wonder: Would programs use that? > > a program could use: > > i = parseInt(x) > > - which can result in undesirable behavior. That is fixed by:- > > i = parseInt(x, 10) > > - or the proposal:- > > if(typeof parseInteger == "function") { > i = parseInteger(x); > } else { > i = parseInt(x, 10); > } > > -which seems a bit clunky.
How about this: parseInt(x, 10) is already the compatible version "parseInteger". You could define the function parseInt to simply throw a typeError if the second argument is missing. Or perhaps to break less existing programs- to throw some kind of error should it recieve a string with a leading zero in the first argument, and there is no supplied second argument. This essentially turns a silent bug into a noisy bug, which may be desirable. _______________________________________________ Es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

