nevalang / neva

🌊 Dataflow programming language with static types and implicit parallelism. Compiles to native code and Go
https://nevalang.org
MIT License
91 stars 7 forks source link

Early return from iterators is not supported #711

Open emil14 opened 3 days ago

emil14 commented 3 days ago

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 #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)?