Re: [heycam/webidl] State that by default all objects are created in the relevant realm of `this` (#135)

So, on the subject of current vs. relevant. A couple weeks ago, a conversation with @TimothyGu had me somewhat-convinced that current is a better default than relevant, despite our upthread resolutions. Similarly, @bzbarsky and I discussed a different case at https://bugs.chromium.org/p/chromium/issues/detail?id=832273 and he was kind of leaning toward current, by my reading.

The argument is basically that we've over-applied the lesson of [navigator.getBattery()](https://w3c.github.io/battery/#dom-navigator-getbattery). The lesson there was that for persistently created-and-stored objects, relevant is better; see the reasoning in the HTML spec example [here](https://html.spec.whatwg.org/multipage/webappapis.html#realms-settings-objects-global-objects) (scroll down to "One reason why the relevant...").

Generalizing that to all cases was, perhaps, a mistake. The getBattery() case is particularly weird because it lazily creates and stores the promise in question. A more normal spec with persistent objects (e.g. the persistent `navigator` object that hangs off of `window`) would just create the objects ahead of time. And indeed, the getBattery() spec could be phrased that way; the lazy-creation seems like an implementation optimization that made its way into the spec.

Arguments for current instead as the default:

- It's what the JS spec does
- It's what is natural if you implement something in JS

We may still need a caveat about persistent objects, but making current the default seems like a good idea. Thoughts, @bzbarsky?

I'm not sure I'll actually make time to formalize object creation and get this straightened out as something we can point people to. But at the very least we could update this thread's title to "current", and update the HTML spec's advice about relevant-by-default.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/135#issuecomment-411109348

Received on Tuesday, 7 August 2018 16:02:10 UTC