I wonder why I have missed this before, but maybe it has been discussed somewhere... I currently want to implement dispatch like
check_tilde_rhs(x::AbstractArray{T}) where {T} = check_tilde_rhs(x, DensityKind(T))
which with the current interface doesn't work.
I'd have expected that DensityKind is defined on the type, and then defaults DensityKind(object) = DensityKind(typeof(object)), just like eltype. Yeah, this kind of defaulting is discouraged, but IMHO sufficiently close to eltype to make sense. I'd even be happy with only the type-based method, but extending the interface is backwards compatible. The only real change would be to require implementors define the type method, not the object method.
Is there any case where DensityKind(typeof(object)) doesn't make sense?
I wonder why I have missed this before, but maybe it has been discussed somewhere... I currently want to implement dispatch like
which with the current interface doesn't work.
I'd have expected that
DensityKindis defined on the type, and then defaultsDensityKind(object) = DensityKind(typeof(object)), just likeeltype. Yeah, this kind of defaulting is discouraged, but IMHO sufficiently close toeltypeto make sense. I'd even be happy with only the type-based method, but extending the interface is backwards compatible. The only real change would be to require implementors define the type method, not the object method.Is there any case where
DensityKind(typeof(object))doesn't make sense?