Questions on number constraints and conversions
Lars T Hansen
lth at acm.org
Mon Sep 3 05:40:29 PDT 2007
On 6/5/07, liorean <liorean at gmail.com> wrote:
> 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:
>
> 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?
Nothing's been discussed, really. Generally the number types are
interconvertible and truncation etc can be hard to control. You could
imagine a type constructor, eg "strict", s.t.
var x : strict int
means x can only convert from the value set implied by int. For
example. But almost certainly not in ES4.
--lars
More information about the Es4-discuss
mailing list