C. Scott Ananian ecmascript at
Thu Jun 12 13:56:01 PDT 2014

On Thu, Jun 12, 2014 at 3:21 PM, Allen Wirfs-Brock
<allen at> wrote:
> It's not obvious to me why we would need @@new in addition to @@create (which is pretty much equivalent to saying it's not clear to me why we need [[Construct]]). For the ordinary case, @@new would just be another level of method lookup and invocation that would be required on each new.  While we expect implementations to (eventually)  optimize all of this, we still tried to minimize the amount of boiler plate work required for each new.

>From my perspective, it's about simplifying the language.  I like the
fact that 'new C' is "just" sugar for an ordinary method invocation on
C.  It would simplify the presentation of the spec as well: various
places that currently state special behavior for "new XYZ" forms could
instead describe the ordinary method XYZ.@@new.   And as Jason points
out, this conceptual simplification of the language translates into
concrete API simplifications for reflective operations like Proxies.

I don't think there are any special security issues involved, since I
can already do: `let x = Reflect.construct.bind(Reflect, C)` and pass
that around.

(fwiw, Crockford's "Simplified JavaScript" in and my own
"TurtleScript" subset of JavaScript in both did away with the new
operator.  TurtleScript replaced it with `Function#New`.)

More information about the es-discuss mailing list