Sorry if this is a common question and I just missed the answer when searching around.
I’m trying to mimic the functionality of a macro by building up an expression similar to what it takes as input, calling the same function the macro calls, and then calling
eval on the resulting expression. I can’t quite seem to make this work, so was hoping for some advice on what to do differently.
We have the following macro in DiffEqBiological:
macro min_reaction_network(ex::Expr, p...) min_coordinate(:min_reaction_network, MacroTools.striplines(ex), p, :no___noise___scaling) end
Typical usage would be
network = @min_reaction_network begin c1, X --> 2X c2, X --> 0 end c1 c2
My understanding is that in the macro definition
ex corresponds to the
end block expression, and
p to a tuple of the symbols at the end
I’m trying to create a package to read in a different network file format and output a
min_reaction_network. My approach was to try to build up an equivalent expression to what gets passed into
min_coordinate, and a similar parameter tuple, and then call
eval on what
min_coordinate returns. The issue is that I don’t seem to be able to quite figure out how to build this expression correctly.
For say the example above, can anyone show me how to build an equivalent expression to what the macro passes to
min_coordinate so that I can call it directly?