Recall that OptionValue
is a "magic" symbol with nonstandard behavior. The expression OptionValue["bar"]
"by magic" gets its value without it being explicitly passed one, working with its "magic" brother OptionsPattern
in a not-entirely-transparent way. I think it attaches to the first OptionsPattern[]
object which is not used in the final matching with "bar" -> 3
.
In version 10.1 from your second block of code I get:
In[6]:= foo["xx", "bar" -> 3]
During evaluation of In[6]:= OptionValue::rep: def is not a valid replacement rule. >>
Out[6]= {"xx", "bar" -> 3, 1}
Did I enter it wrong or has behavior changed?