The MatchParameters Object

Unlike the other Match objects, the MatchParameters (and MatchParamCommutative) objects are one parameter objects. The single parameter is always a pattern and these objects are used to match against parameters passed into functions.

Clauses in object definitions typically contain at least one MatchParameters object. For example, suppose we have a function named MyFn which contains the clause:

The term on the left-hand side is a MatchParameters object. If we execute this function on "x + y", (so we are executing MyFn[x + y]), then the expression that is actually processed is:

So the MatchParameters object is just a placeholder for a Match object that is populated with a parameter passed into the function call.

The MatchParameters object also works with functions with more than one parameter. So if MyFn2 is defined as:

and we execute MyFn2[x, y-1], then the clause that is executed is: