JuliaMath / JuliaMath/IntervalSets.jl
Override `*` and `^` in a way that different packages can interpret the result differently
- Dominant language
- Julia
- Stars
- 109
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
In ApproxFun.jl, I'd like to do function approximation on a square via:
```julia
Fun((x,y) -> exp(x*y), (0..1)^2)
```
Of course, `(0..1)^2` has a completely different interpretation in the setting of ValidatedNumerics.jl. Overriding `^` in either package would be type piracy.
My proposal is to add a placeholder type to this package that can be interpreted by other packages however they please:
```julia
# in IntervalSets.jl
struct IntervalProduct{NT<:Tuple}
intervals::NT
end
*(a::AbstractInterval, b::AbstractInterval, c::AbstractInterval...) = IntervalProduct(a,b,c...)
```
Then ApproxFun can override `Fun(::Function, d::IntervalProduct)` to interpret `d` as a rectangle, while ValidedNumerics.jl can override `ValidatedNumerics.Interval(::IntervalProduct)` to interpret it as an interval arithmetic operation.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.