macros can be made to work like subs, you just need to know a few tricks to get it to work the same way. macros just works in a slightly different manner and we can make it useful.
The difference is with subs, one has to keep specifying the substitution with each equation you want subbed, whereas macro will already have it defined. As an example:
a := v^2*z^3 - 34/(5*x^2*sin(y*v^2)) + 36*v^2 - b*v^2 + 3^(v^2 - cos(v^2 + g))
If we want to substitute h for v^2, then we would normally do this using subs
however, we can also use macro
now it doesn't just automatically substitute those values so we need to coax maple a little bit. We can do that by converting the equation to a string and parsing it.
so as you see we arrive at the same result. Now there is a caveat using macro, if you've already defined a variable in a macro, subs will not work using the same variable sustitution - you first need to reset the variable in the macro back to itself.
#doesn't work since the variable is defined in a macro
macro(v^2=v^2) #reset the variable in the macro
# now it works
we could also define a little procedure to simplify our typing, to have the macro variable work on our equation.
mvs:=proc(a) #macro variable substitution
now if we had some other existing equation before defining the macro
we just have to simply apply our proc on the equation to apply the variable substitution