Once we have type guards, I would expect the JavaScript programming style to 
slightly change. Currently, number-valued arguments are implemented like this:

    function foo(x) {
        x = Number(x);
    }

With guards, you would use:

    function foo(x :: Number) {
    }

It might make sense to standardize simple guard methods now, for example:

    function foo(x) {
        Object.guard(x, Number);
    }
    
Advantages: Helps tools (to infer types, to generate documentation), can later 
be refactored to real guards.

-- 
Dr. Axel Rauschmayer
a...@rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com



_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to