I wish to generate code like
Base.:(<)(a::∂ℝ{N},b::∂ℝ{N}) where{N} = <(a.x,b.x)
for all possible operators, and all sorts of combinations of input types. I need the “Base.” qualifier because I am in a module. I write a little code generator
for OP in (:(>),:(<),:(==),:(>=),:(<=),:(!=)) #...
eval(quote
$OP(a::∂ℝ{N},b::∂ℝ{N}) where{N} = $OP(a.x,b.x)
$OP(a::ℝ ,b::∂ℝ{N}) where{N} = $OP(a ,b.x)
$OP(a::∂ℝ{N},b::ℝ ) where{N} = $OP(a.x,b )
end)
end
The problem I see is that my macro generates something like
<(a::∂ℝ{N},b::∂ℝ{N}) where{N} = <(a.x,b.x)
that is, my “Base.” qualifier is missing. I have tried to modify my metacode to do that, without success:
Base.:( $OP)(a::∂ℝ{N},b::∂ℝ{N}) where{N} = $OP(a.x,b.x)
does not do the trick. “LoadError: < not defined for…”
And I would like to add: same question in a macro, where I should replace OP with esc(OP) .