The new operator

Axel Rauschmayer axel at rauschma.de
Sat May 12 17:08:13 PDT 2012


Until ES.next, I’ve stuck to the simple rule: Always use `new` when you want to create an instance. That avoids confusion when it comes to functions such as String and Boolean: I like using them to coerce values.

Given that value object constructors such as uint64 are currently invoked without `new`, I’m wondering whether that rule changes:

- Do we still need `new`? If we had class declarations, their desugared versions could easily always create new instances, whether invoked via `new` or as a function. The same holds for object exemplars: Calling such an exemplar could “instantiate” it.

- Should there be alternate, possibly less confusing, ways of coercing values? ToPrimitive() would certainly be nice to have.

Axel

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120513/7316449c/attachment.html>


More information about the es-discuss mailing list