Metaprogramming: substitute the name of the argument

You don’t generally need metaprogramming for this. Just use higher-order functions.

For example, this seems to match the pattern you want?

fun_mix(fun1, fun2) = (u; wt=0.5, kws...) -> wt * fun1(u; kws...) + (1-wt) * fun2(u; kws...)

giving e.g.

julia> fmix = fun_mix(sin, cos)
#19 (generic function with 1 method)

julia> fmix(0.3)
0.6254283478934728

julia> fmix(0.3; wt=0.9)
0.3615018349077662
6 Likes