w3ctag / promises-guide

A guide for spec authors on how to use Promises in prose and WebIDL.
https://www.w3.org/2001/tag/doc/promises-guide
192 stars 24 forks source link

Promise-manipulation shorthands have underdefined behavior #52

Closed bzbarsky closed 5 years ago

bzbarsky commented 7 years ago

https://www.w3.org/2001/tag/doc/promises-guide#shorthand-manipulating says:

If the algorithm using these shorthands is running in parallel, the shorthands queue a task on p’s relevant settings object’s responsible event loop to call the stored function.

But to queue a task you need to know the event loop and the task queue to use. Which task queue is used here?

annevk commented 7 years ago

I think I mentioned this somewhere as a reason that this guide basically cannot be used directly by specifications.

@tobie or someone else should take the time to integrate it into IDL as only IDL-derived specifications will be in need of this kind of language.

domenic commented 7 years ago

Another issue is that people often want to use them on Web IDL objects, which are realm-agnostic. But we need to call the ES-spec algorithms with JS objects, which are not. So we need a specific global in which to do the conversion from IDL object -> JS object conversion.

I was going to say that this should be the global of the promise by default, to save people typing. But then I remembered that promises, as ES spec objects, don't have associated globals. So that's fun.

bzbarsky commented 7 years ago

Web IDL objects are not realm-agnostic, if you mean platform objects. https://heycam.github.io/webidl/#es-platform-objects says:

Every platform object is associated with a global environment, just as the initial objects are. It is the responsibility of specifications using Web IDL to state which global environment (or, by proxy, which global object) each platform object is associated with.

and conversion to an ES object creates an ES object in that global (though this last part should probably be more clearly specified).

Now if you try to pass and IDL dictionary in, then you have a problem.

domenic commented 7 years ago

Good point, I got confused because my first example was a sequence of strings. I'll work to rephrase https://github.com/whatwg/html/pull/2774.

bzbarsky commented 7 years ago

Right, sequences have the same problem as dictionaries...

domenic commented 5 years ago

Fixed by https://github.com/heycam/webidl/issues/490!