obsoleting the "new" keyword

Mark S. Miller erights at google.com
Fri Jan 30 08:12:01 PST 2009

On Fri, Jan 30, 2009 at 12:19 AM, Garrett Smith <dhtmlkitchen at gmail.com>wrote:

> No offense, but that is some ugly code.

Indeed. We wouldn't have written it if the language didn't force us to.

> [...]
> To supply varargs to that constructor, use a newApply function.
> Function newApply, for a constructor C:
> 1) create a dummy function F
> 2) assign the C's prototype to F
> 3) create a new F, as i
> 4) call C.apply(i, arguments)

Your step #3 still fails for the reason I stated earlier:

> Won't work on Array, Date, RegExp, and Function, since o is created with
> [[Class]] "Object". But should work otherwise.

If your technique did work on, for example, Date, then we wouldn't need the
ugly code. I suggest you try your ideas on Date.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20090130/7a98a1d5/attachment-0001.html>

More information about the Es-discuss mailing list