Steven Johnson stejohns at adobe.com
Thu Aug 14 10:40:33 PDT 2008

On 8/14/08 6:25 AM, "Neil Mix" <nmix at pandora.com> wrote:
> It sounds like static type checking infers a certain
> amount of "hard failure," i.e. you can't run this until you fix your
> code.  That's not really what I'm voting for.  I just want it to be
> possible, somehow, to catch simple type errors very early in the
> development process, and then to run the same type annotated code
> unchanged in the browser.

Depends on what you mean by "hard failure". If we have a function like

    // n must be a numeric type
    function sqrt(n) { ... }

then the ability to say

    function sqrt(n:Number) { ... }

only requires that n by convertible-to-Number at runtime. (If not, ES4/AS3
required that a TypeError be thrown.)

This does make it possible to do some static type checking at compile-time,
of course (and the AS3 compiler can optionally do this).

Personally, I like catching stupid mistakes of this sort as early as
possible, so I tend to use type annotations everywhere I can when I code in
AS3. Your mileage may vary.

More information about the Es-discuss mailing list