W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2013

Re: [promises] Difficulties with using constructors and promises together

From: Mark S. Miller <erights@google.com>
Date: Thu, 20 Jun 2013 13:00:21 -0700
Message-ID: <CABHxS9iT27CjxwBHE_68Bzf8GEgP9JoGRVPoQzCmxC2AcxtkdA@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
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,
    --MarkM
Received on Thursday, 20 June 2013 20:00:49 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:49 UTC