I suspect that there is a simple and idiomatic solution, but I have to admit that with this meandering topic I no longer have a clear idea what the problem is.
If you want collect the arguments a function was called with, you could define a container and make it callable. Eg
struct CollectingVector{T}
vector::Vector{T}
end
CollectingVector{T}() where T = CollectingVector(Vector{T}())
function (cv::CollectingVector)(x)
push!(cv.vector, x)
nothing
end
julia> cv = CollectingVector{typeof((J_δ = 1.0, c = 1.0))}(); # template for type
julia> cv((J_δ = 1, c = 2))
julia> cv.vector
1-element Array{NamedTuple{(:J_δ, :c),Tuple{Float64,Float64}},1}:
(J_δ = 1.0, c = 2.0)
You almost certainly don’t need metaprogramming, but instead of learning about very basic things like loops and composite types (stuct
) in the course of solving the problem, you may benefit from just working through the manual first.
Julia is a powerful language, but you won’t be able to harness that power without making an initial investment in some structured form.