Number handling

Yehuda Katz wycats at gmail.com
Tue Oct 30 12:55:09 PDT 2007


After playing with the ES4 RI yesterday, my biggest concern comes from the
handling of various number types as compared to other types:
* Literal numbers become ints, rather than Numbers. While ES4 is still
compatible with ES3 via some very strange use of the constructor property,
doing something like: var x:Number; x = 7; throws an error.
* ints are coercive by default. So function foo(x:int) { return x };
foo(null) returns 0, while function foo(x:Number) { return x }; foo(null)
returns null. In effect function foo(x:int) { return x } is identical to
function foo(x:*) { return new int(x) }
* This is the same for all "primitives" like double.
* I understand that this does not break strict compatibility with ES3, but
it certainly breaks conceptual compatibility, because adding in simple
typechecking to an existing ES3 app will break things unless the programmer
learns the new paradigm for handling primitives.

Of course, it's possible that some of this is just a failing in the
reference implementation, but looking through the available materials leads
me to believe that it's not *all* RI-related.

-- 
Yehuda Katz
Web Developer | Procore Technologies
(ph)  718.877.1325
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.mozilla.org/pipermail/es-discuss/attachments/20071030/7cb7a0cb/attachment-0002.html 


More information about the Es4-discuss mailing list