Re: Context Names Question (2)

*To*: mathgroup at smc.vnet.net*Subject*: [mg3997] Re: [mg3919] Context Names Question (2)*From*: Allan Hayes <hay at haystack.demon.co.uk>*Date*: Tue, 14 May 1996 02:14:02 -0400*Sender*: owner-wri-mathgroup at wolfram.com

Dave Wagner is rightly concerned about my using the System context to solve Xah Lee's problem [mg3919] Context Names Question > Suppose I have two packages, TrochoidPlot and TrochoidShow for > example. Both packages use the option name RotationRange for > several of their functions. > Shadowing of RotationRange will occur after loading the second > package. > Is there some code one can execute before or after loading so the > option RotationRange can be recognized in functions from either > package? (I copy the solution at the end of this message.) he writes >You are defeating the whole point of contexts by doing this! But Xah's problem must be a common one - I frequently run into it. So, here's another try: We seem to need a common context on the context path for all of a class of packages. Put BeginPackage["Xah`Common`"];EndPackage[]; at the head of each package in the class so that whenever one of them is loaded the context "Xah`Common`" is put on the context path. Then use "Xah`Common`" like I used "System`" Thus: BeginPackage["Xah`Common`"];EndPackage[]; BeginPackage["Xah1`"]; Xah`Common`opt::usage = "Message 1"; EndPackage[]; BeginPackage["Xah`Common`"];EndPackage[]; BeginPackage["Xah2`","Xah1"]; Xah`Common`opt::usage = "Message 2"; EndPackage[]; Allan Hayes hay at haystack.demon.co.uk ************** Begin forwarded message: Xah: A simple solution is to create the option RotationRange in the System context, usually in your usage messages for the packages: System`RotationRange::usage = "RotationRange is an option for the packages TrochoidPlot and TrochoidShow ...." You may prefer different wording, for example a general form like "RotationRange is an option for several packages ..." With more code you can arrange for the usage messages for several packages to cummulatively add their information to that already stored on the option. Example: BeginPackage["Xah1`"]; System`opt::usage = "Message 1"; EndPackage[]; ?opt Message 1 BeginPackage["Xah2`"]; System`opt::usage = "Message 2"; EndPackage[]; ?opt Message 2 Allan Hayes hay at haystack.demon.couk ==== [MESSAGE SEPARATOR] ====