Re: Generators and accumulators Lassi Kortela 21 Jan 2020 23:15 UTC

> Generators can be wrapped around *any* source of data, at the
> expense of being unable to inline it unless you have a whole-program
> compiler.  If you are able to use an explicit lambda that gets inlined,
> so much the better, but I think the normal use case will be something
> quite different.

You're right. Cross-module analysis is much more difficult.

What about a generator that returns substrings of the source data
instead of chars, and then the parser would consume those strings as if
they were concatenated to form the complete stream? It seems like it
would be faster not to call the generator separately for each char. But
maybe these are unfounded concerns and I should run a concrete example
through a profiler.