Re: [whatwg/streams] Editorial: use dictionaries for { value, done } and eliminate "forAuthorCode"? (#1036)

Oh, you're totally right. Dang.

Streams is in a peculiar position where it is using promises for internal flow control (throughout the spec ecosystem) as well as externally exposed to web developers. Everything else in the ecosystem only uses promises at the developer boundary, and uses "async algorithms" of some sort internally. Those async algorithms are sometimes informal, and sometimes formal (using mechanisms like "in parallel", "queue a task", etc.). https://github.com/whatwg/infra/issues/181 touches on this more.

So I think if we were to do anything here it would be best to make streams behave more like the rest of the ecosystem. In particular, I think

> the only solution I came up with was to have something almost but not quite the same as a Promise to use internally

is right, but I wonder if we'd be able to do that surgically, in only the places that handle chunks. I.e., keep using promises for closed/ready/the return values of the underlying X methods/etc. But for ReadableStreamDefaultReaderRead / [[PullSteps]] / read(), do something a bit different, passing the raw chunk around (not in promise form), until finally wrapping it up right before returning from read().

If this is surgical enough, then perhaps we could just use "spec callbacks". Callbacks are gross and messy compared to promises, but if you only go through one or two algorithms using them, it might not be so bad.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1036#issuecomment-634146982

Received on Tuesday, 26 May 2020 16:53:33 UTC