Hi there!
I am new to this discussion, I was wondering whether there are any plans to add a pattern matching function definition besides multiple dispatcher.
Let me give an example, in Wolfram Mathematica it is possible to define a function such as:
f[a_. + b_ ] = a+b /; FreeQ[a + b x, x]
That is, this function returns a+b if matched, 'a' is optional, 'b' is required but we have the condition that a + b x can't be an expression in x. This would match '1/x', 'z + 1/x', 'Unevaluated[z + 0]', '-1 + x' etc.
An other example:
f[Sin[ x_ ]] = x
matches only the sinus as the trunk of the expression tree, and the sinus' content is passed as a parameter to f.
The SymPy project has a pattern matching system (unfortunately, unlike Mathematica, it does not declare any functions in such a way), employing Wild objects, which can match any expression tree.
Are there any plans to introduce such an advanced feature into Julia? I suppose that a pattern matcher to define functions would require a non-constant-time search algorithm, decreasing performance if such patterns are used, but that would be really very useful in symbolic math.