- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Thu, 20 Jun 2013 12:38:57 -0700
- To: "Mark S. Miller" <erights@google.com>
- Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
On Thu, Jun 20, 2013 at 11:22 AM, Mark S. Miller <erights@google.com> wrote: > Not sure I like this: > > What about invoking the constructor function as a function, i.e., without > the "new". If it cannot create the object synchronously, then it can't > return the object synchronously, so there really is no constructor function > per se. So the name may as well just name a factory function which is just > called normally. Yeah, I don't like this either. I think it violates Least Surprise - when the new-less constructor function works, it usually just still returns a new object in practice. (I do this sometimes when I'm gonna use a constructor a *ton* - just start the function with "if(!(this instanceof MyClass)) return new MyClass(arg1, arg2);".) ~TJ
Received on Thursday, 20 June 2013 19:39:43 UTC