Here's a macro that just has the effect of combining the code that would
check each variable's length into a short form. It refers to the input
variables both by name and value.
macro lencheck(l,vars...)
exprs = Expr[]
for v in vars
sym = string(v)
push!(exprs,:(if length($v) != $l error(string($sym," must be
length ",$l)) end))
end
Expr(:block, exprs...)
end
Invoke with: @lencheck 5 x y z #etc...
On Monday, February 9, 2015 at 1:06:25 AM UTC-5, Dominique Orban wrote:
>
> That's what I used to do, but because there will be several such optional
> args, I need to be able to tell which doesn't have the right size.