domenic / promises-unwrapping

The ES6 promises spec, as per September 2013 TC39 meeting
1.24k stars 95 forks source link

Formalize ThenableCoercions Weak Map #39

Closed domenic closed 10 years ago

domenic commented 11 years ago

The ES-type notation at the very least is not going to fly. It might suffice to just define three abstract operations, ThenableCoercionsHas(thenable), ThenableCoercionsGet(thenable), and ThenableCoercionsSet(thenable, promise).

Specifying their behavior also needs to get a bit better. For example, it should probably be a per-realm weak map. Perhaps we associate a [[ThenableCoercions]] internal property %ThenableCoercions% intrinsic to the realm's global, then treat it like a [[WeakMapData]].

The actual weakness can be explained in a line or two of prose referring to weak map objects.

domenic commented 10 years ago

@allenwb, what do you think of the above strategy ("For example... perhaps we associate...")? Alternately, could I just assign new internal data properties to the thenables, i.e. thenable.[[Promise]]? I don't think anything else in the spec does that, but I think it would be the same... Upon learning more about internal data properties that seems like a really dumb idea, nevermind.

domenic commented 10 years ago

Closing in favor of the work going on in #62. See https://github.com/domenic/promises-unwrapping/tree/bring-back-thenable-coercions#the-thenable-coercions-weak-map for my new take on how to specify this. I anticipate using the caller function's [[Realm]] internal property as the first argument to ThenableCoercionsGet/ThenableCoercionsSet.