Optional argument types

Andreas Rossberg rossberg at google.com
Tue Sep 25 07:37:39 PDT 2012


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


More information about the es-discuss mailing list