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

Early return from iterators is not supported #711

Open
emil14 opened this issue Sep 28, 2024 · 1 comment
Open

Early return from iterators is not supported #711

emil14 opened this issue Sep 28, 2024 · 1 comment
Assignees
Labels

Comments

@emil14
Copy link
Collaborator

emil14 commented Sep 28, 2024

In imperative programming you can stop iteration by using break or return keywords, but in Nevalang's dataflow it's not possible - for, map, filter, etc will process the whole stream even if its infinite. How do we solve this problem?

  1. Implement Iterator protocol (early termination for stream processing for both parent and child) #666 and use it for all iterators? Wouldn't that be hard to use?
  2. Make existing iterators send -> :err to signal stop? Is it popular usecase enough to make using more complicated (in theory you could just not write to :err outport)
  3. Introduce other components for this usecase (e.g. While)?
@emil14 emil14 self-assigned this Oct 4, 2024
@emil14
Copy link
Collaborator Author

emil14 commented Oct 4, 2024

:err outport problem

In Go you if err != nil and return err inside for loop, in Nevalang you can't do anything if inside handler of your for/map/flter/etc you got :err from somewhere. You basically can't use ? operator too


Maybe #724 can be used for loop too?

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

No branches or pull requests

1 participant