4 comments

[ 4.8 ms ] story [ 16.8 ms ] thread
Are there any examples of C++ text/streaming libraries implementing fusion in a similar way?
Not that I'm aware, although I spotted this one on github: https://github.com/mikea/cpp-stream-fusion, based on a paper discussed at the time on HN: https://news.ycombinator.com/item?id=5507204

Stream fusion (or deforestation, in general) is useful in languages that encourage function composition. For that, functions must receive and return a value that can be composed together. In my experience, languages in the style C or C++ encourage functions that modify the argument in place (caller supplies their own buffer, for example), which bypasses the problem of creating intermediate copies of the final result.

That is a good point. Thanks.
Just made me think. Linear types coming into Haskell should allow this sort of thing to be done in like in C++, avoiding the problem of worrying about fusion and compiler rewrite rules.