Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Share symbols among packages

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97383] Re: Share symbols among packages
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 12 Mar 2009 02:18:50 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <gp82if$2l4$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

if you don't give a context, Mathematica assume that it
is the current context. You must specify the context
explicit with MyPack1`myVar and clearly MyPack2 must not
define also myVar.

Regards
   Jens

Andrey wrote:
> 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
> 


  • Prev by Date: Re: Maintaining a Mathematica bug list
  • Next by Date: RE: Re: Wolfram/Alpha (Wikipedia page restored)
  • Previous by thread: Re: Share symbols among packages
  • Next by thread: Re: Share symbols among packages