I am building a fairly large application in Mathematica, and globally scoped variables are causing issues.
I would like globally scoped variables to be out-of-scope for my expressions, except by request.
Here is a simple, albeit contrived, example (where //GlobalScope is something with the intended behavior, I guess):
B := 0;
f[x_, m_, b_] := m*x + b;
Manipulate[
Plot[
f[X, M, B],
{X, 0, 10}
],
{M, 0, 10},
{B, 0, 10}
]//GlobalsAvailable
should be allowed, but
B := 0;
f[x_, m_, b_] := m*x + B;
Manipulate[
Plot[
f[X, M, B],
{X, 0, 10}
],
{M, 0, 10},
{B, 0, 10}
]//GlobalsAvailable
should not be allowed.
I'm also open to suggestions which fix the underlying problem (which is caused by the combination of mutability, global scope and the reactive development style encouraged by notebooks).
LocalizeVariables -> False
, then variables associated with the controls will have global scope.x = 10; {Manipulate[x, {x, 0, 40}, LocalizeVariables -> False], Dynamic[x]}
By defaultManipulate
usesLocalizeVariables -> True
Is this what you needed? $\endgroup$