Closed vincentcp closed 4 years ago
Because it’s inherited from IntervalSets.jl, where type stability is necessary. It’s not clear what the best solution is: the alternatives would be to always return a UnionDomain
Right, IntervalSets.jl
has chosen to remain type-stable by only ever returning a single interval when using union
. We can't really change that behaviour in DomainSets.jl
, otherwise behaviour depends on whether users loaded our package or not. This does mean, unfortunately, that one can not rely on union
always working. The UnionDomain
constructor does always work, but it doesn't simplify (i.e. it won't fuse overlapping intervals into one).
This leaves room for a uniondomain
function which attempts to simplify before falling back to UnionDomain
. But that won't map to the infix operator for unions.
Unfortunately, I don't think the list of domains for which union
can be both simplifying and type-stable is very long (overlapping intervals is one... anything else?). So, not ideal, leaving the issue open :-)
The situation has not changed, it seems clear we are not going to diverge from what IntervalSets
does. Closing this for now.