A common idiom for me when operating on a struct is to assign local names for members of the struct. That is, if the argument is
A with members
baz I often begin a method with
function myfunc(A) foo, bar, baz = A.foo, A.bar, A.baz ... A end
The purpose is to avoid repeated extraction (the compiler may optimize it away but I don’t think that is a certainty) and to make the code somewhat cleaner.
I notice when checking allocations with
--track-allocations that there is apparently a considerable amount of allocation at those lines. Am I shooting myself in the foot by doing this? I was under the impression that this would just assign some pointers or, at worst, scalars in the evaluation frame of the method.
Is it best to avoid assigning a tuple when doing this?
I have only tested in version 0.5.0 - my package has dependencies that are not satisfied in 0.6.0-dev yet.