Questions on number constraints and conversions

liorean liorean at gmail.com
Tue Jun 5 13:56:49 PDT 2007


Hello!

After discussion in a thread on ECMAScript binding of the DOM I came
to wonder a bit of what type of type contraints ES4 actually will be
able to have:

1. ES3 array.length is constrained so that if setting the value is
converted ToUInt32(rhs) and a TypeError is thrown if that value is not
equal to ToNumber(rhs). Is this type of type constraint possible in
ES4 short of using a setter (ignoring the fact that this type
constraint is not all that setter would have to deal with)?


2. Also, conversions between the types. Is is possible to have a type
constraint of uint that does not wrap around negatives but instead
throws if the value is not part of the value set of uint for example?

Similarly a type constraint of int and a value larger than 0x7fffffff
throwing instead of of wrapping around into the negatives?
-- 
David "liorean" Andersson



More information about the Es4-discuss mailing list