Description
cfr JuliaMath/IntervalSets.jl#170 (comment)
I'd argue the contract is different for types inheriting from Domain
and types implementing the domain interface.
One difference is ownership. The DomainSets
package can't provide untyped fallback definitions, even if they make sense, for functions defined elsewhere. It can define untyped fallback definitions for functions specifically defined for domains (which, currently, is typically reflected in the name of the function). In the latter case, specifying the type of an object expected to be a domain to be ::Domain
can be replaced by a call to checkdomain
on the argument to catch any user errors.
In general it can define fallbacks only for arguments of type DomainRef
, since we own that type. By inheriting from Domain{T}
, a type opts-in to such fallback behaviour, without requiring its users to sprinkle their codes with DomainRef
for statements that make complete sense without.
Unless I missed some kind of mechanism, not having an optional common supertype implies DomainRef
's all over the place or being restricted to functions that are used only specifically in the context of DomainSets
(i.e. being less generic).