[Proposal] Option to generate stream from `for`

36 views
Skip to first unread message

luk...@niemier.pl

unread,
Jul 22, 2021, 6:56:13 AM7/22/21
to elixir-lang-core
Currently, while there is `:into` option in `for`, there is no way to make it into "regular" stream. It would be handy to have a way to either make something like:

```
for a <- 1..10, b <- 1..10, into: Stream, do: {a, b}
```

Or have additional option:

```
for a <- 1..10, b <- 1..10, stream: true, do: {a, b}
```

That would make `for` to return stream. This can be handy in cases where resulted list would be so huge, that it would start to be problematic for VM to catch up.

José Valim

unread,
Jul 22, 2021, 8:02:34 AM7/22/21
to elixir-l...@googlegroups.com
"into: Stream" plays well with the current semantics where "into: ..." changes the return value however, because emitting a stream would require "for" to emit a completely different code than today, "into: Stream" would only work if the Stream module is given at compilation time. In a nutshell, this is welcome, but it is a relatively high amount of work.



--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/671c053f-359e-4b35-b696-4e262de30583n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages