Skip to content
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

Closed
domenic opened this issue Sep 28, 2017 · 2 comments
Assignees
Labels
editorial Changes that do not affect how the standard is understood

Comments

@domenic
Copy link
Member

domenic commented Sep 28, 2017

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) .

@domenic domenic added the editorial Changes that do not affect how the standard is understood label Sep 28, 2017
@domenic domenic self-assigned this Sep 28, 2017
@domenic domenic changed the title Make it easy to create streams with no underlying source/sink/transformer objects Make it easy to create streams with no underlying source/sink/transformer objects, from specs Sep 28, 2017
@ricea
Copy link
Collaborator

ricea commented Nov 7, 2017

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.

@domenic
Copy link
Member Author

domenic commented Nov 16, 2017

Maybe we'd even abstract out the promise-stuff too so those steps don't have to return promises.

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.

domenic added a commit that referenced this issue Nov 16, 2017
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.
domenic added a commit that referenced this issue Nov 16, 2017
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.
domenic added a commit that referenced this issue Nov 16, 2017
domenic added a commit that referenced this issue Nov 18, 2017
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.
domenic added a commit that referenced this issue Nov 18, 2017
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.
domenic added a commit that referenced this issue Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial Changes that do not affect how the standard is understood
Development

No branches or pull requests

2 participants