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

Janet streams and abstract types. #1155

Open
zevv opened this issue May 24, 2023 · 3 comments
Open

Janet streams and abstract types. #1155

zevv opened this issue May 24, 2023 · 3 comments

Comments

@zevv
Copy link
Contributor

zevv commented May 24, 2023

Is there any official consensus and/or documentation on the implementation and use of abstract/OO types for streams in Janet?

  • What methods is a stream required to implement to be considered a "stream"? For example, ev/ streams seem to offer the :close, :read, :chunk and :write methods, but net/ has a bunch more (:flush, :accept, etc)
  • Is networking (library) code that builds on streams encouraged to use abstract method calls instead of calling net/... or ev/... functions directly? For example, Spork's HTTP code at this time depends directly on ev/... functions, which makes it hard (impossible) to re-use this code when running on my own stream types.
@sogaiu
Copy link
Contributor

sogaiu commented May 24, 2023

I don't know of a consensus or docs.

Assuming there aren't issues for drafting something along these lines, may be some of the above text is a good start :)

@bakpakin
Copy link
Member

:close, :read;, :chunk, and :write are certainly what I would want to implement. If you use these methods, really are just using duck-typing for the streams, which is fine but you may want more. For example, :flush might make sense here but :accept probably does not.

@zevv
Copy link
Contributor Author

zevv commented May 24, 2023

I think it would be helpful to define and document the mandatory set required to implement a stream so producers know what to offer, and consumers know what is safe to call without run time errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants