Sorry, this is not an answer to your question, but are you absolutely sure that it cannot be solved without metaprogramming? This problem seems too simple to use such a technique.
Maybe this discourse thread can be of interest: How to warn new users away from metaprogramming there are some good proposals, how one can solve problems in base Julia, without turning to macros and other things.