Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override * and ^ in a way that different packages can interpret the result differently #27

Open
dlfivefifty opened this issue Mar 21, 2018 · 0 comments

Comments

@dlfivefifty
Copy link
Member

In ApproxFun.jl, I'd like to do function approximation on a square via:

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:

# 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant