I’m trying to create a Type that broadcasts like a Number without being <: Number, see example code below. I tried the following, but broadcasting is returning a zero-dimensional array where Numbers return a Number.
It looks like broadcast is overriden for Number, is overriding the only way to replicate the behaviour of Number? This is unfortunate as I would like to mix-and-match Number and Foo (and of course Vector{<:Number} and Vector{Foo}).
In preparation to 0.6, in 0.5 I am using something like
"Making types work with `broadcast` and dot-syntax in 0.5."
macro ensure_broadcast(typ::Symbol)
VERSION ≥ v"0.6.0-" && return nothing
quote
Base.size(::$typ) = ()
Base.getindex(f::$typ,::CartesianIndex{0}) = f;
end
end
but I am wondering if there is going to be something like this in Compat, or is that only backward-looking?