Josh,

Many thanks! That works very well. I'm quite bummed as to why the 
symbol-based approach isn't working (or the syntax for it is to elusive). 
It seemed that iterating over variables using symbols would be the thing to 
do, but maybe not.

Cheers!

On Monday, February 9, 2015 at 3:27:46 PM UTC-5, Josh Langsfeld wrote:
>
> 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. 
>
>

Reply via email to