I'm writing a function that takes optional arguments. Many of them must be
arrays of a certain size. I'd like to perform a quick check of their size
at the top of the function and thought it would be a good use case for meta
programming, but I can't seem to get the syntax right. Here's an example
that hopefully illustrates what I'm trying to do:
function test(a; x=zeros(5), y=zeros(5))
for arg in {:x, :y}
if length(eval(arg)) != 5 # ERROR: x not defined
error(@eval $(string(arg, " must have length 5")))
end
end
# ...
end
I tried *@eval $(arg)* in the argument to *length*, but without success.
Line 3 always causes "ERROR: x not defined" to be raised.
Thanks!