Re: Creating entangled objects

On Mon, Mar 9, 2015 at 6:57 PM, Jonas Sicking <jonas@sicking.cc> wrote:
> But how does the call that create the two objects create them? If not
> through their constructor?

Prose algorithms.

Here's how the precedents, `new Promise(executor)` and
`Proxy.revocable(target, handler)`, are specified in ES6:

*   https://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-executor
    (particularly note how CreateResolvingFunctions, called in step 9,
    explicitly creates objects and POKEs references to each other into them)

*   Proxy.revocable is clearer:
    https://people.mozilla.org/~jorendorff/es6-draft.html#sec-proxy.revocable
    See step 4.

So the spec has a way to say "ok, create a bunch of objects and hook
'em up like so", but scripts don't. A bit of "putting magic into the
API" seems unavoidable to me, as this is exactly the property you're
after, right?

-j

Received on Tuesday, 10 March 2015 21:13:01 UTC