Parsimonious way to unpack big structs

Well, there is the “somewhat dangerous” unpacking available from Parameters.jl. From the documentation,

function fn(var, pa::Para)
    @unpack_Para pa # the macro is constructed during the @with_kw
                    # and called @unpack_*
    out = var + a + b
end

where a and b are fields unpacked from Para. They admonish to be careful with this, as it can collide/shadow other variables.

5 Likes