jeremito wrote:
> I am a beginner in package development in Mathematica. I need a
> package because I have several functions that call each other that
> depend on the same data. Instead copying and passing the data around,
> I want to have the functions all access the data directly.
>
> My package currently looks like:
>
> f[A_, x_] := Module[{},
> b = A.x;
> Return[{b,A}];
> ]
It would be much better to write it as follows (local variables and no
Return statement):
f[A_, x_] := Module[{b},
(* b is now a local variable to the function f *)
b = A.x;
{b,A}
(* Last expression is returned if it does not end by a semicolon *)
]
(* b is not visible outside the scope of Module *)
> g[A_, l_] := Module[{},
> ....
> (*You get the picture*)
> ]
>
>
> So my question is, how can my variables have package scope, but not
> global scope? What is the best way to implement this?
Not sure what you mean by that. Are you talking about contexts? In this
case, the following might help:
http://reference.wolfram.com/mathematica/tutorial/Contexts.htmlhttp://reference.wolfram.com/mathematica/tutorial/ManipulatingSymbolsAndContextsByName.htmlRegards,
-- Jean-Marc