The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: LocalizeVariables doesn't!
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Frank Iannarilli

Posts: 106
Registered: 12/13/04
LocalizeVariables doesn't!
Posted: Jan 1, 2012 2:28 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

My reading of Docs on the LocalizeVariables->True option of Manipulate[] is that all variables associated with Controls will be localized (inside a DynamicModule). To prevent "local" Manipulate variable name leaks into the Global namespace, I declare them as "dummy" controls, using: ControlType->None. But this evidently doesn't work as I'd expect:

Try the following execution sequence:

(* should NOT list myPicture as a variable *)

symbolLeaker[]:= Manipulate[.... (* definition cell later below *)
symbolLeaker[] (* Invoke it *)

(* myPicture now shows up in the Global` namespace !??! *)

What gives?



symbolLeaker[] := Manipulate[

myPicture = Table[Sin[i*j/cdivisor], {i, 1, 32}, {j, 1, 32}];
ListPlot3D[myPicture, PlotLabel -> "Image", PlotRange -> All],

(* >>>>>>> CONTROL/LAYOUT SECTION <<<<<<<<< *)
Item[Style["Symbol Leaker", 16, Bold, Brown], Alignment -> Center],
{{cdivisor, 64, "Sine Inverse Freq."}, Range[4, 128]},

(* Dummy control variables,
which are actually variables we'd like to keep localized to within \
this Manipulate, or otherwise they'd leak out as session-
global variables. A good rule of thumb:
if a variable is included in TrackSymbols, it better be localized.
True localizes variables associated with Controls. *)
{myPicture, ControlType -> None},

(* Manipulate options *)
LocalizeVariables -> True,
TrackedSymbols :> {cdivisor},
ContinuousAction -> False

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.