Non-allocating loop over a set of structs

Why did you think a loop and unrolled code would be exactly the same? Unrolling something like for i in 1:1000000 is clearly not a good idea. A loop, by its definition, is executing the same code multiple times. Since samples contains heterogeneous type, “the same code” needs to be something generic that can handle things with different types.

Of course, a loop can be unrolled but it is not obvious for code like this when doing so is beneficial.

1 Like