Optional argument types
Andrea Giammarchi
andrea.giammarchi at gmail.com
Tue Sep 25 08:17:57 PDT 2012
I wonder if nothing came out at ES4 time about this topic ... AS2 ES4 like
approach wasn't that bad, imho
function doStuff(key:String, value:Object):Boolean {}
this was permissive without types ...
function setIntoMap(map:Map, key, value:Object):Map {}
this was good help before execution ... this wasn't big deal with overloads
( not supported as it is already in JS )
At that time, I really liked this approach but I am sure you know it pretty
well too :)
On Tue, Sep 25, 2012 at 4:03 PM, Alex Russell <slightlyoff at google.com>wrote:
> It's far too early to tell. I strongly prefer structural, but again,
> backing a type system into ES isn't something to do lightly. It has huge
> consequences that extend well beyond the grammar changes.
>
>
> On Tue, Sep 25, 2012 at 3:59 PM, Andrea Giammarchi <
> andrea.giammarchi at gmail.com> wrote:
>
>> then nominal will be? :)
>>
>>
>> On Tue, Sep 25, 2012 at 3:37 PM, Andreas Rossberg <rossberg at google.com>wrote:
>>
>>> On 25 September 2012 15:31, Andrea Giammarchi
>>> <andrea.giammarchi at gmail.com> wrote:
>>> > That's a hell of a question ... shapes speaking I'd say structural,
>>> since
>>> > AFAIK shapes are those boosted up more, isn't it?
>>> >
>>> > That would solve String VS string and Array VS Arguments which is, I
>>> > believe, kinda desired.
>>> >
>>> > Which one would you chose ?
>>>
>>> I assume that most people would probably prefer structural types in
>>> principle, but the problem is that they induce far, far more expensive
>>> runtime checking (easily an order of magnitude). Which is why guards
>>> and trademarks were proposed as a more conservative, nominal
>>> mechanism.
>>>
>>> Generally speaking, retrofitting something type-like on an untyped
>>> language is a *very* hard problem. It has been tried with many
>>> languages and has succeeded for very, very few. You can read lots and
>>> lots of research papers on the subject.
>>>
>>> Fortunately, though, we have top-notch expertise on that topic on
>>> TC39, e.g. Sam TH. ;)
>>>
>>> /Andreas
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120925/3495da97/attachment.html>
More information about the es-discuss
mailing list