In julia 0.7, I had overloaded
Base.ifelse(cond::π,a::βπ£{N},b::π£) where{N} = cond ? a : βπ£{N}(b)
Base.ifelse(cond::π,a::π£,b::βπ£{N}) where{N} = cond ? βπ£{N}(a) : b
essentialy so that
x=cond ? a : b
would promote the output, to get a typestable operation when a and b have different types.
Porting to 1.0, I get LoadError: cannot add methods to a builtin function
. In the context of automatic differentiation, this allows me to transparently write typestable code when some variables may be βspiced upβ as dual/autodiff numbers.
I could write a function ifthen, with the obvious drawback of forcing the evaluation of both a and b. I could write a macro, but then I can no longer write a function ignoring automatic differentiation ('xept for dispatchingβ¦) and then use it efficiently with automatic differentiation.
Any ideas?