On Aug 22, 2014, at 1:45 PM, Rafael Fourquet <fourquet.raf...@gmail.com> wrote:
> 
> In short, be lazy when it gives opportunity for loop fusion, and saves 
> allocations.

There's a complicated limit to when you want to fuse loops – at some point 
multiple iterations becomes better than fused loops and it all depends on how 
much and what kind of work you're doing. In general doing things lazily does 
not cut down on allocation since you have to allocate the representation of the 
operations that you're deferring and close over any values that they depend on.

This particular example only works out so well because the iterable is so 
simple that the compiler can eliminate the laziness and do the eager loop fused 
version for you. This will not generally be the case. You're welcome to 
experiment (and Julia's type system makes it pretty easy to do so), but I think 
that you'll quickly find that more laziness is not a panacea for performance 
problems.

Reply via email to