Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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:

?Global`*
(* should NOT list myPicture as a variable *)

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


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


What gives?

Thanks,
Frank


----------------------


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],
Delimiter,
{{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.
LocalizeVariables->
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]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.