W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2014

Re: [webidl] Defining constructors on non-global objects?

From: Rick Waldron <waldron.rick@gmail.com>
Date: Fri, 5 Sep 2014 12:04:03 -0400
Message-ID: <CAHfnhfpR60W_Tjw=Gmc+CqSSvW+3fr11fMvycvMQsNyUn6a4RQ@mail.gmail.com>
To: Domenic Denicola <domenic@domenicdenicola.com>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On Fri, Sep 5, 2014 at 10:00 AM, Domenic Denicola <
domenic@domenicdenicola.com> wrote:

> From: Boris Zbarsky [mailto:bzbarsky@mit.edu]
>
> > If this is the API you want, then for the moment you can define an
> AmbientLight factory method that returns an object of the right type, and
> the "new" call above will work due to how "new" works in JS.  But the
> returned object won't be instanceof Sensor.AmbientLight, and won't have
> Sensor.AmbientLight as its .constructor
>
> I think it would be better not to do that. The approach I would take is,
> make up a fictitious syntax for now (we can brainstorm on that if you'd
> like) and we will be sure to get it into WebIDL before your spec needs to
> ship.
>
> Because I am passionate about not letting WebIDL restrict good design, I
> personally will volunteer to do the work of speccing this for you. Although
> that will be dependent on implementer consensus, as such a change to IDL's
> capabilities would need to be reflected in their code generators... :-/
>
> That said, what does the Sensor constructor do by itself?
>

Currently: nothing.

Rick
Received on Friday, 5 September 2014 16:04:52 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:22 UTC