Agreed. Since posting I have liked this even less. I withdraw the suggestion. On Thu, Jun 20, 2013 at 12:38 PM, Tab Atkins Jr. <jackalmage@gmail.com>wrote: > 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 > -- Cheers, --MarkMReceived on Thursday, 20 June 2013 20:00:49 UTC
This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:13 UTC