Re: What is the point of having Initializations in

*To*: mathgroup at smc.vnet.net*Subject*: [mg123040] Re: What is the point of having Initializations in*From*: Mike H <mike.honeychurch at gmail.com>*Date*: Mon, 21 Nov 2011 04:28:32 -0500 (EST)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*References*: <CAAMnnc871YstsdaSWSWYU_uD88e=8Z3cPn+rGSO1jZ19uuaZTQ@mail.gmail.com>

John, I do NOT expect plot or g to dynamically update. That is not what this is about. On Mon, Nov 21, 2011 at 5:34 PM, John Fultz <jfultz at wolfram.com> wrote: > On Mon, 21 Nov 2011 15:57:00 +1100, Mike H wrote: > > So the output cell containing the list {plot, "Silder", g[0]} is not a > > display of the DynamicModule? > > To refresh, the code you included was... > > DynamicModule[{c}, {plot, Slider[Dynamic[c]], g[Dynamic@c]}, > Initialization :> (g[x_] := Cos[x]; plot = Plot[g[x], {x, 1, 10}]), > UntrackedVariables -> {g}] > > * plot is not in a Dynamic. You get exactly what the Shift+Enter > evaluation > gave you. > * g[] is not in a Dynamic (regardless of what argument you pass it). You > get > exactly what the Shift+Enter evaluation gave you. > > The Shift+Enter evaluation has completed long before the DynamicModule is > displayed and the Initialization is executed. > > And the fact that you expected g[Dynamic@c] and/or Cos[Dynamic@c] to > return > anything sensible (which I had overlooked in your example before) > indicates that > you are failing to understand some really fundamental stuff about Dynamic. On the contrary I have already repeatedly explained what I expect: that is that plot would appear as the rendered plot because its global value was set during the initialization. As far as my lack fundamental understanding of Dynamic goes I repeat again that the example was provided to me by Wolfram Research Inc. It is also worth noting that when given the example I was also advised by Wolfram Research that "The evaluation of g here is triggered by making the argument to g dynamic." I actually disagree with that advice provided to me by *your company* and in fact it is wrong -- making the argument does not trigger the evaluation of g. So rather than cast aspersions about my understanding of Dynamic you might want to consider the knowledge base within Wolfram. > See > here: > > http://forums.wolfram.com/mathgroup/archive/2010/May/msg00440.html > > and especially the post I link to here: > > http://forums.wolfram.com/mathgroup/archive/2009/Feb/msg00424.html > > Simply put, what is the value of? > > Cos[Dynamic[Pi]] > > Answer...Cos[Dynamic[Pi]], but because of the way Dynamic typesets, it > will look > like Cos[Pi] (because Dynamic[Pi] looks like Pi). That is because > Dynamic[Pi], > in the Shift+Enter evaluation, always evaluates to Dynamic[Pi]. Dynamic > is a > HoldFirst function which never evaluates its argument...it merely creates a > front end construct which evaluates and displays its argument. > yes. I agree but repeat that it is your colleagues providing this example g[Dynamic[c]] My question is solely about why the global value is not rendered. I am not suggesting or expecting these variables to be dynamic so lets get back on point. > > > > > > I understand the point you make about if a colon were placed and no > > output were generated but what is your definition of "first displayed"? > > It actually shows up in the front end. > > I > > guess this must be another point of difference because I would consider > > the first display of the dynamic module as being the first time I see the > > list {plot, "slider", g[0]} rendered. > > Yes, that's correct. But why would you expect 'plot' or 'g' to magically > update, since they are not inside of Dynamic? > I don't expect them to "update." I expect them to have global values at the time of the rendering. The values are set once only. Based on the language which you say you are going to re-write, I expect an initialization to set plot to the graphic (once) and then when the dynamicmodule content is evaluated and the rendered output shows the graphic. > > > > So when I first see {plot, "slider", g[0]} the initialized value of plot > > and g are not rendered. Apologies if it seems I'm laboring this point but > > it remains confusing. > > > So it seems that the key to understanding this now becomes what the > > definition of "display" is. Am I correct is saying that if a > > DynamicModule is displayed -- and I await what this means -- the > > initialization will have taken place and therefore the initialized value > > will be shown in the display? > > The initialization will have taken place, but initialized values will only > show > if the FE is kicking off further evaluations to actually display > them...which is > what Dynamic does. > > We're going in circles here, I do not understand how, if the initializations have taken place, prior to the evaluation of the the list (contents of the DM) that plot is not rendered as a graphic. If the initialization has taken place then Global`plot must surely have a value at the time the next step is executed -- which is the evaluation of the DM body. If I had evaluated plot=Plot[x,{x,0,1}] in a separate cell prior to evaluating the DM the global value of plot would be (and is) shown in the display. It is not a question of whether plot is updated -- I don't expect it to be and don't want it to be (otherwise I would use Dynamic) it is a question of whether the global value of plot is set in the initializations prior to the evaluation of the body. If you have an evaluation order like this: evaluate initialization plot = plot[....] then evaluate {plot, slider, g[0]} then I am still struggling to see how the global value of plot would not be used in the displayed list. Mike > > > FWIW I had assumed a display to be the rendered output. > > That is correct. > > > > > thanks > > > > > > Mike > > Sincerely, > > John Fultz > jfultz at wolfram.com > User Interface Group > Wolfram Research, Inc. > >

**Re: Problem displaying user-created .cdf files**

**Re: Problem displaying user-created .cdf files**

**Re: solving 8-dimensional ODE-System - error**

**Re: What is the point of having Initializations in**