Optional argument types
concavelenz at gmail.com
Tue Sep 25 15:45:45 PDT 2012
On Tue, Sep 25, 2012 at 9:12 AM, Brendan Eich <brendan at mozilla.org> wrote:
> John Lenz wrote:
>> that should have been "unrelated structures can look the same".
> Right. Robert O'Callahan mocks this as "structural types are about field
> names, nominal types are about class names".
> Clearly, "duck typing" structural protocols (iteration in ES6) have
> advantages as well as costs. Array-like is the first of this kind. We
> aren't against such things, the issue Andreas raises is the researchy
> nature of doing anything you could call a type system for a language such
> as JS -- whether structural or nominal types -- or both -- are included.
> I should also note that the Closure Compiler types system was based off
>> the ES4 proposal, if you want to see how things played out.
> Did you include all the "like" non-type crazy?
It isn't a complete implementation and completely static (runtime type
check injection is optional and rarely used).
> One thing that I have seen specifically, is that supporting "non
>> nullable" types, and distinguishing between "undefined" and "null" in the
>> type signature creates a fair amount of busy work ("type casts" to remove
>> nullability) for larger projects.
> Yes, it's like const. You have to rule out null at an API boundary or
> other chokepoint, and then go non-null in the "kernel". C and C++
> programmers do this by hand (references in C++ only help so much -- and
> they give no runtime safety).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss