4 ms·
In languages with more leeway on execution order, this problem can be made to go away. For example, Haskell's stream fusion combines back-to-back calls to list
by Tuna-Fish 12y ago
In languages with more leeway on execution order, this problem can be made to go away. For example, Haskell's stream fusion combines back-to-back calls to list processing functions into a single iteration over the list.
- seanmcdirmid 12y agoLazy evaluation can also be encoded fairly easily in strict languages using constructs like lazy stream abstractions.
- jeremyjh 12y agoUh, sure but does any other language have a compiler that actually implements stream fusion?
- DanWaterworth 12y agoI don't believe GHC actually does implement stream fusion. I think stream fusion happens with rewrite rules.
- riffraff 12y agopardon my ignorance, but what would be the difference between the two? Don't rewrite rules happen in GCH anyway?
- DanWaterworth 12y agoSorry, I should have been clearer. The rewriting happens in GHC, but it's the application programmer who creates the rules. So, stream fusion isn't implemented by the compiler AFAIK.
- riffraff 12y agoah that makes sense, thanks.
- gazarsgo 12y agoNot in the compiler, but enjoy a Microsoft Research paper about Steno, a C# library that claims to be superior to stream fusion (section 8.2): http://research.microsoft.com/pubs/173946/paper-pldi.pdf http://research.microsoft.com/pubs/173946/paper-pldi.pdf In case anyone is unaware, LINQ lets you represent queries as a series of function calls which it represents as a series of Expression objects and an in-memory AST.
- seanmcdirmid 12y agoThere is also the dynamic language run-time (DLR), which as a generalization of LINQ (to support statements) is pretty powerful when writing up these tools on .NET. I use it often in my work.