-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it easy to create streams with no underlying source/sink/transformer objects, from specs #813
Comments
Is there existing standard language for storing "algorithm steps" in a slot, or would we have to invent some? In Javascript and C++ it concretely means storing a bound function. That needs to be reasonably obvious to implementors. I would also like these algo slots to have associated data, so we don't have a separate slot to store the "pull" function for an underlying source that will be totally unused in a TransformStream. We also need language for creating a stream object without calling the public constructor. |
I started doing this and it caused more trouble than it's worth in the short term. E.g. you end up converting from promises to async algorithms back to promises, which in theory adds an extra microtask, and in any case is awkward to follow. (Not sure if the microtask is observable though, since I don't think any code can interleave between them.) So we can leave that for another day, perhaps when add the concept of "asynchronous algorithm" or "spec promise" to Infra. |
As part of #813, the [[underlyingSource]] and [[underlyingByteSource]] slots are going away, and so will no longer be suitable for brand checks. This instead uses the [[controlledReadableStream]] and the newly-renamed [[controlledReadableByteStream]] slots.
Part of #813. This has the normative effect of changing the length property of the ReadableStreamDefaultController constructor, as now we initialize them without using the constructor.
As part of #813, the [[underlyingSource]] and [[underlyingByteSource]] slots are going away, and so will no longer be suitable for brand checks. This instead uses the [[controlledReadableStream]] and the newly-renamed [[controlledReadableByteStream]] slots.
Part of #813. This has the normative effect of changing the length property of the ReadableStreamDefaultController constructor, as now we initialize them without using the constructor.
I had an epiphany while reading #811. We don't necessarily need to block that on solving this, but I wanted to record it.
Once #691 is fixed, we'll have a slot in the classes for the appropriate functions from the underlying source/sink/transformer. We should take this a step further, and have the slot store "algorithm steps" instead of JavaScript functions.
For the constructor-generated instances of each class, we'd store algorithm steps that are just
Call(func, ...)
basically. But this would allow us to easily create instances of streams with specific algorithm steps from specs without indirecting through JavaScript objects and classes. For example it would simplify https://fetch.spec.whatwg.org/#concept-construct-readablestream .Maybe we'd even abstract out the promise-stuff too so those steps don't have to return promises.
This is related to #372 (comment) .
The text was updated successfully, but these errors were encountered: