Re: Passing default options to nested function call
- To: mathgroup at smc.vnet.net
- Subject: [mg94039] Re: Passing default options to nested function call
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Wed, 3 Dec 2008 05:41:46 -0500 (EST)
- References: <10132325.1227952316551.JavaMail.root@m02> <ggtv8o$7fv$1@smc.vnet.net> <gh2h5n$ib8$1@smc.vnet.net>
Hi, > > What I really do is something like this: > > Options[fun1] = Join[{opt1 -> 1},Options[Graphics]] > > so that > > fun1[opts:OptionsPattern[]] > > doesn't complain if I supply Graphics options to fun1. > > My original question still stands: Is it safe to assume that only the > first value for an option will be used, when there's more than one > value for that option in the list? Hm, as long as there is no explicit remark of that in the documentation, it is probably not safe since it could depend on the implementation of OptionValue, although I think it is very unlikley that it will ever change... But for your specific problem, probably the following is doing what you want without the need to rely on that particular behavior of OptionsPattern and OptionValue: Options[fun1] = Join[{opt1 -> 1}] fun1[opts : OptionsPattern[{fun1, Graphics}]] := OptionValue[{opt1, Axes}] hth, albert