The implementation of the built-in OptionValue
contains some piece of magic so that
OptionValue[name]
is equivalent toOptionValue[f, name]
, wheref
is the head of the left-hand side of the transformation rule in whichOptionValue[name]
appears.
Does anybody have an idea for how to achieve something similar for Options
, i.e. implement an autoOptions[]
that would resolve to the options defined for the symbol on the left hand side of the transformation rule in which autoOptions[]
appears?
For clarity, what I am looking for is a way to make
Options[foo]={bar->1};
foo[OptionsPattern[]]:=autoOptions[]
foo[]
output {bar->1}
The eventual goal is to do something like requested in this question without having to change anything but the RHS of a definition.