Newbie question about loop fusion and broadcasting

Yes, that’s exactly right. For example: v .* v' .+ 2 is effectively the same as:

vt = v'
broadcast((x, xt)->x*xt + 2, v, vt)

Had I written this as v * v' .+ 2, then we’d first compute the result of * (regardless of the implementation of *) and then do the broadcasted addition, effectively:

temp = v * v'
broadcast(x->x+2, temp)

The consecutively-connected dots are how we define what goes into that inner “kernel” (the anonymous function in the cartoon equivalence above). To make this even more clear, you can compare the result of zeros(5) .+ rand() vs. zeros(5) .+ rand.().

4 Likes