Re: [streams] Define the streams interface only with publicly visible behavior (#312)

Hmm, there might be some confusion here.

The current spec does define the interface in terms of its publicly visible behavior. It does so by giving one algorithm that will produce the normatively-required results. But if you have another algorithm that would do so, and is black-box indistinguishable, that is also a fine way of implementing the spec.

For example, the queue-with-sizes data structure is fantastically inefficient as specced. Presumably one would instead keep track of the sizes as things are added and removed from the queue. The key thing is that that behavior is black-box indistinguishable from the behavior specced (which sums up all the sizes every once in a while).

The danger of something like https://github.com/whatwg/streams/blob/asyncbytestream/BinaryExtension.md is that it does not give precision to interactions between different parts of the API, especially things like interaction between the underlying source and the stream's methods, or the sequencing of different events (calling read() twice, etc.). I think the better path is to produce a full algorithmic specification of the methods (and validate the algorithm with a reference implementation), as we have been doing.

>From another angle, perhaps the main part of this issue is the idea of how to state invariants and contracts that must apply to all readable streams. That's what I think the templated tests accomplish. We could expand those a bit (to allow porting more existing tests) if we allowed templated "actions", e.g., create a stream, run some test code, then run an action like erroring the stream, then run some more test code.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/312#issuecomment-88496523

Received on Wednesday, 1 April 2015 14:06:26 UTC