On Sep 27, 2013, at 10:14 AM, David Herman <dher...@mozilla.com> wrote:

> On Sep 27, 2013, at 10:02 AM, David Herman <dher...@mozilla.com> wrote:
> 
>> - don't share symbols between workers
> 
> Follow-up thought: it seems there are actually two concepts that both get 
> grouped under "realms" and yet might warrant distinction. These correspond on 
> the web to two same-origin windows vs two workers.
> 
> Between same-origin windows, you have different realms but a shared heap. In 
> that case, you really want e.g. @@iterator to be === regardless of the realm 
> it comes from. If one same-origin window shares an iterable object with 
> another same-origin window, we want it to remain iterable. So we really want 
> to specify that within a heap, multiple realms can share symbols (there's no 
> way to stop them from sharing them anyway) and the ES6 standard symbols are 
> unique. This also means that you want one registry shared across realms 
> within that heap. I still don't think this needs new mechanism from the 
> language, though, since same-origin windows can synchronously communicate to 
> handshake on a shared registry object.

Another follow-up: even easier than creating some new registry is just to use 
the module registry. You can do that when creating a new realm by simply 
sharing an existing module instance:

    var newRealm = new Loader(...);
    newRealm.set("serialize", System.get("serialize"));

Or if you're implementing a web library and you want to be sure that all 
windows see the same symbol the module can initialize its own symbols by 
querying the environment to see if the symbol already exists:

    // serialize.js
    let m = window.top.System.get("serialize");
    export const serialize = m ? m.serialize : new Symbol("friendly name");

Dave

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to