Re: [w3ctag/design-reviews] Realms API ECMAScript Proposal (#542)

Follow on personal questions about state management and crossing Realm boundaries.

I understand that if `importValue` returns a callable then the callable gets wrapped in a function that marshals the arguments/return value across the Realm boundary, but does that get recursive? e.g. if when invoked, the callable returns another callable, does that get wrapped too? Does the secondary callable have access to other state in the Realm? How does this work with closures?

Here's an example, consider the following (off the cuff, untested) code being imported into a Realm:
```
export function doSomething() {
  const x = { y: 0 };
  return function() { x.y = x.y + 1; return x.y; }
}
```
I then do:
```
const doSomething = realm.importValue('module.js', 'doSomething');
const increment = doSomething();
console.log(increment(), increment());
```

What gets logged? '1 1', '1 2', or ?


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/542#issuecomment-840852543

Received on Thursday, 13 May 2021 21:44:13 UTC