Re: Share symbols among packages

*To*: mathgroup at smc.vnet.net*Subject*: [mg97395] Re: [mg97355] Share symbols among packages*From*: "David Park" <djmpark at comcast.net>*Date*: Thu, 12 Mar 2009 02:21:02 -0500 (EST)*References*: <33371659.1236766572734.JavaMail.root@m02>

I wouldn't declare the same variable name in two packages. 1) You could declare it in one of the packages, and include that package name in the second package BeginPackage statement so the second package would know about the variable. 2) Don't include myVar in either package, but write the definitions of myFun1 and myFun2 so they include data as a parameter. muFun1[data][a,b,c], say, or myFun1[data,a,b,c]. David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: Andrey [mailto:andrey.siver at gmail.com] Hello group, How to use Global symbols in several user packages? That is, I have: BeginPackage["MyPack1`"] myVar::usage="My var"; myFun1::usage="My fun1"; Begin["`Private`"]; ... (* use myVar *) ... End[] EndPackage[] BeginPackage["MyPack2`"] myVar::usage="My var"; myFun2::usage="My fun2"; Begin["`Private`"]; ... (* use myVar *) ... End[] EndPackage[] And then I would like to do like this: myVar=data; myFun1[a,b,c] myVar=data; myFun2[a,b,c] The problem is: myVar::shdw: "Symbol myVar appears in multiple contexts \!\({\"MyPack1` \", \"MyPack2`\"}\); definitions in context \!\(\"MyPack2`\"\) may shadow or be shadowed by other definitions." Any ideas? Regards, -Andrey