Open caridy opened 8 years ago
update1: this was updated to reflect some of the consensus from yesterday's meeting. We still need answer for q2, q3, and q4.
q4 is clearest. The init
method on the spawned realm should definitely not attempt to side effect any state in the parent. In any case, when the parent is transitively immutable, any such attempt must fail anyway.
q3 yes. In general spawned realms should be full fledged realms that differ in how they are constructed, and therefore in what initial state they start with. Once initialized, ideally, they function just as any other realm object would.
Unless there's a reason not to of course. Does such uniformity create any problems?
q2 not currently AFAIK. The frozen realm proposal does not itself need to provide any such means. If the realm API evolves into something that is sufficiently expressive that the answer to q2 is yes, that would probably be good. But I don't think it affects the frozen realm proposal.
q2 is sound good to me, we can eventually introduce an API to create spawn realms. The only issue is that this is related to q3 in the sense that the hooks are extracted from the this during construction, and allocated into the Realm Record, this will make impossible for the current spec to provide custom hooks for spawned realms because they have a very peculiar construction process.
As for q4, if you have access to the spawned realm, you can always do:
let parentGlobal = Object.getPrototypeOf(spawnRealm.global);
Object.defineProperties(parentGlobal, spawnRealm.stdlibs);
which is equivalent to calling spawnRealm.init()
, whether that fails or not depends on the state of the global object.
Based on the new realm API, these are some of the questions:
Question 1: getPrototypeOf
Can spawned realms be created in user-land using an API other than
parentRealm.spawn()
?Question 3: hooks
Can spawned realms define custom hooks for indirect eval and direct eval?
Question 4: init
Should
init()
method attempt to set intrinsics (from parent realm) into fresh global? or should it attempt to set intrinsics in the parent realm's global object? e.g.:Question 5: eval method