Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationship between spawned realm objects and their parent realm object #26

Open
caridy opened this issue May 9, 2016 · 6 comments
Open
Labels

Comments

@caridy
Copy link
Collaborator

caridy commented May 9, 2016

Based on the new realm API, these are some of the questions:

Question 1: getPrototypeOf

Object.getPrototypeOf(spawnedRealmObj) === parentRealmObj; // true or false?

answer: true

Question 2: constructor

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.:

spawnedRealmObj.init();

Question 5: eval method

spawnedRealmObj.eval === parentRealmObj.eval; // based on the current realm spec, this can be true.

answer: yes, this is plausible.

@caridy caridy added the question label May 9, 2016
@caridy
Copy link
Collaborator Author

caridy commented May 11, 2016

update1: this was updated to reflect some of the consensus from yesterday's meeting. We still need answer for q2, q3, and q4.

@erights
Copy link
Collaborator

erights commented May 11, 2016

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.

@erights
Copy link
Collaborator

erights commented May 11, 2016

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?

@erights
Copy link
Collaborator

erights commented May 11, 2016

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.

@caridy
Copy link
Collaborator Author

caridy commented May 11, 2016

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.

@caridy
Copy link
Collaborator Author

caridy commented May 11, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants