OptionsPattern
was introduced in Mathematica v6 so I have finally decided to give a try.
Look at this program:
Clear@foo;
foo[options : OptionsPattern[]] := {options}
foo[k2 -> 3]
foo[Indexed[k, 2] -> 3]
out:
{k2 -> 3}
foo[Indexed[k, {2}] -> 3]
The rule with compound left hand side has not matched OptionsPattern[]
.
You can replace Indexed by any function (Power
, Subscript
), it will be the same.
Now compare with old style option pattern:
Clear@foo;
foo[options___Rule] := {options}
foo[k2 -> 3]
foo[Indexed[k, 2] -> 3]
out:
{k2 -> 3}
{Indexed[k, {2}] -> 3}
Matching occurs in all cases.
Is there a bug in OptionsPattern
?
Manipulate
orPlot
. $\endgroup$