Re:Swift and the Legacy of Functional Programming
by harpocrates on Monday November 21, 2016 @06:27PM
(#13010264)
> so they would not allocate an intermediate list
Not quite. Lazy sequences make it so that thinking about fusion/deforestation makes sense. This is an optimization the compiler can make. Naively, you still end up with as many allocations as before (just in a different order).
In Haskell, this sort of optimization is actually user-customizable using REWRITE RULES. And you get it for lists out of the box.
Not quite. Lazy sequences make it so that thinking about fusion/deforestation makes sense. This is an optimization the compiler can make. Naively, you still end up with as many allocations as before (just in a different order).
In Haskell, this sort of optimization is actually user-customizable using REWRITE RULES. And you get it for lists out of the box.