Re: Transparently passing on options to other functions
- To: mathgroup at smc.vnet.net
- Subject: [mg82314] Re: Transparently passing on options to other functions
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Wed, 17 Oct 2007 04:08:25 -0400 (EDT)
- References: <ff1ofp$861$1@smc.vnet.net>
Hi, and the good old method f[OptionsPattern[{}]] := OptionValue[optf]; Options[g] = {optg -> True}; g[opts : OptionsPattern[]] := (optg /. {opts}) && f[opts] no warnings and that is the way that options are processed since version 1.0 ... I would suggest,to use OptionPattern[] only for complicated cases like g[Method->{"HumptyDumpty","Horse"->2,"Wall"->tooHigh},MaxSteps->500] where you have multiple nested options. BTW OptionValue[] may be usefull if you have a single option but normaly one writes {thisOption1,thisOption2,thisOption3,thisOption4}= {Option1,Option2,Option3,Option4} /. {opts} /. Options[ThisFunction]; instead of {thisOption1,thisOption2,thisOption3,thisOption4}= OptionValue /@ {Option1,Option2,Option3,Option4}; Regards Jens Art wrote: > Let functions f and g be defined as follows: > > f[ OptionsPattern[{}] ] := OptionValue[optf]; > > > Options[g] = {optg -> True}; > g[opts : OptionsPattern[]] := OptionValue[optg] && f[opts] > > The following gives a warning that optf is not an option value for > function g. > > g[optg -> False, optf -> False] > > > Is there a good way to have OptionValue ignore this fact and not generate > a warning? What is the proper way to transparently pass through options to > other functions? > > I would like to not do the following: > > Options[g] = {optg -> True, optf -> Null}; > > which eliminates the warning. > >