This is clever! I was thinking I had to look at CodeInfo
to implement @lazy
. I didn’t realize it can be done elegantly by overloading Broadcast.broadcasted
.
Regarding the performance, I think reduction via iterators is not the right direction to get a “zero-cost abstraction”. If fusing map and reduction becomes a thing in Julia, I think the right abstraction for the backend is the transducer (a shameless plug).