Skip to content

DensityKind(::Type) #12

Closed
Closed
@phipsgabler

Description

@phipsgabler

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions