Closed mschauer closed 23 hours ago
@mschauer, thank you for noting this. I was pretty busy when you contributed this comment, and it fell off my radar--sorry for my slow response!
I think that the suggestion sounds reasonable. I'm not sure if or when I'll have a chance to look at this, but if you have time and want to explore contributing something like this to Match.jl, I'd be happy to consider it.
Macros cannot be extended, but inversefun
can easily be made a function instead of a macro. One potential problem is that functions can't be dispatched on. Here's a very inelegant possible solution:
immutable Inverse end
f(x) = x^2
f(::Inverse, x) = sqrt(x)
that is, using the inverse function as a method of the original. This probably has ambiguity problems, and it doesn't strike me as very Julian.
This is very similar to https://github.com/JuliaServices/Match.jl/issues/92.
Treating as a dup of #92, which is probably closer to how we would handle this.
I am thinking since a while, that it would be nice and very julian to match general functional expressions if the inverse of the function is provided, for example
would translate into
where
@inversefun
can be extended.