From: Ariel Sepulveda on
Itsvan:

Assigning values inside Initializaiton causes the DynamicModule to change
last session values with initialization values. My opinion is that this is
not wrong but is not what is intended/expected from DynamicModule. You can
try creating both cases and then comparing behavior after quitting Kernel.

Ariel

On Wed, Jan 20, 2010 at 7:51 AM, Istv=E1n <replicatorzed(a)gmail.com> wrote:

> Thank you for the extensive help.
> For those who are interested, and could not see the replies I got
> (*OFF* I still don't understand fully the posting behaviour of this
> interface: I got at least 4 emails, but none of them shows up in the
> web interface. If I reply to the emails, then I assume no post will
> show up in the group's archive. Therefore I always post using the web
> inteface. Is there a better way to do this? *ON*), I will recapitulate
> the solution.
> The "assign" and "initialize" functions should be defined with
> DownValues instead of OwnValues, that is:
>
> assign[]:=(...) instead of assign:=(...),
>
> although the fact that simply OwnValues won't work here goes against
> my intuition. Also it is not clear (although Ariel shed some light on
> it) what is the exact difference between calling the functions assign
> [] and initialize[] at the end of the Initialization option or at the
> start of DynamicModule, right after defining local variables:
>
> DynamicModule[{assign,x,y},(*dynamic expression to
> show*),Initialization:>(assign[]:=(y=x);assign[]a)]
> vs.
> DynamicModule[{assign,x,y},assign[];(*dynamic expression to
> show*),Initialization:>(assign[]:=(y=x))]
>
>
> Furthermore, Norbert has pointed out, that my model can be further
> simlified to this:
>
> DynamicModule[{something},1,Initialization:>(something:=(Print["you
> should never see this!"]);)]
>
> returning 1, and the string is printed as well, which effectively
> demonstrates, that DynamicModule evaluates even those expressions,
> which shouldn't be evaluated. Unfortunately, this example, and the
> following one (still from Norbert) completely freezes my Mathematica
> 7.0 (I have to kill it from TaskManager), so I can't even confirm.
> Anyone else has problems evaluating these examples, or you all can run
> them as Norbert does?
>
> DynamicModule[{x=False,something,i=0},{
> RadioButton[Dynamic[x,(x=#)&],True],
> RadioButton[Dynamic[x],False],
> Dynamic[i]},
> Initialization:>(something:=(Print["init",i++]))
>
>


--
Ariel Sepulveda, Ph.D.
__________________________
President, Pronto Analytics Inc.
Tel. 787.354.6947
ariel.sepulveda(a)prontoanalytics.com
http://www.prontoanalytics.com