> Axel Rauschmayer wrote:
>> 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.
> User-defined constructors are often coded so that users must invoke via new.
> This may happen, therefore it does happen, and it won't go away. I don't know
> why you are treating ES.next as some slate-cleaning exercise, below ("Do we
> still need ..."). The answer by default is "yes".
Right. Sorry if I gave off that impression. I’m mostly thinking about how to
keep JavaScript easy to teach. And with value object constructors we now have
three ways of creating instances (new Foo(...), Foo(...), foo(...)). If we want
to reduce the number of ways, there are two possibilities: (1) Advocate that
people use the `new` operator less. (2) Write uint64(123) as new UInt64(123) or
as UInt64(123). With literal syntax such as 123L, decision (2) might not even
matter much.
Another possibility is that we want to emphasize that value object constructors
are a different beast. Then using lowercase names can provide a good visual
clue.
In other words: I’m trying to figure out how value object constructors fit into
the current picture.
--
Dr. Axel Rauschmayer
[email protected]
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss