Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

LocalizeVariables doesn't!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123940] LocalizeVariables doesn't!
  • From: Frank Iannarilli <frankeye at cox.net>
  • Date: Sun, 1 Jan 2012 02:27:01 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Reply-to: comp.soft-sys.math.mathematica at googlegroups.com

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
  ]



  • Prev by Date: Erf funcion
  • Next by Date: What is the recommended way to set up definitions for or initialize a palette?
  • Previous by thread: Re: Erf funcion
  • Next by thread: What is the recommended way to set up definitions for or initialize a palette?