MathGroup Archive 2009

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

Search the Archive

shadow warning with function parameters and local module variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104994] shadow warning with function parameters and local module variables
  • From: brien colwell <xcolwell at gmail.com>
  • Date: Tue, 17 Nov 2009 05:13:52 -0500 (EST)

hi all,

I have a set of fairly complex packages. Frequently I use the same 
variable names in function definitions and local modules across many 
packages. Sometimes I see this type of warning:

    <varname>::shdw : Symbol <varname> appears in multiple contexts {*}; 
definitions in context * may shadow or be shadowed ...

This does not happen with symbols in the package context (already 
fixed); it happens only with function parameters and variables in local 
modules. I can recreate the warning with the following code snippet. It 
seems to me that the variable 'v' should be safely local to each module. 
Is there really a symbol conflict to worry about here?

thanks,
Brien


In[1]:=
BeginPackage["a`"];
Test1[t_] := Module[{v = t + 1}, t + v];
EndPackage[];
BeginPackage["b`"];
Test2[t_] := Module[{v = t + 2}, t + v];
EndPackage[];

Out[1]:=
v$::shdw: Symbol v$ appears in multiple contexts {b`,a`}; definitions in 
context b` may shadow or be shadowed by other definitions. >>





  • Prev by Date: Re: Fyi, Listing of Mathematica 7 functions (1869 functions)
  • Next by Date: Re: NDSolve problem
  • Previous by thread: How to use a discretized controller with NDSolve?
  • Next by thread: Re: shadow warning with function parameters and local