Re: How to Enable Automatic Recalculation

*To*: mathgroup at smc.vnet.net*Subject*: [mg109945] Re: How to Enable Automatic Recalculation*From*: John Fultz <jfultz at wolfram.com>*Date*: Wed, 26 May 2010 07:07:38 -0400 (EDT)

Well, I suppose that we will have to agree to disagree on this point. I think that Dynamic brings two really great strengths to Mathematica. One is that it enables the building of tools like Manipulate. Without generic dependency tracking, building Manipulate would have been a tremendous challenge. With it, it's so ridiculously easy that somebody outside of WRI could have put it together with no more than Dynamic/DynamicModule, a paper clip, a rubber band, and a bit of chewing gum. :) In fact, that's is exactly what I do in this talk which I gave at IMS 2006: http://library.wolfram.com/infocenter/Conferences/6876/ Second, I think you underestimate how difficult event-handling is for people who have not had extensive education or experience in software development. I would argue that complex interfaces are just going to be complex, no matter how you try to tackle them...but most simple interfaces are *much* simpler when implemented using a dependency-tracking approach then they are when implemented using event-handling techniques. We do, of course, support EventHandler, and there are some things possible using EventHandler which are difficult or nigh impossible to do using Dynamic. But my experience is that 90% of what one would generally want to do in practical interfaces can be accomplished much more easily in Dynamic then anything one might imagine constructed with EventHandler. Sincerely, John Fultz jfultz at wolfram.com User Interface Group Wolfram Research, Inc. On Fri, 21 May 2010 06:45:23 -0400 (EDT), Nasser M. Abbasi wrote: > hi Murray; > > I do not think using Dynamics is a good idea. For me Dynamics is like got o > on steroids, it makes it much harder to understand the logic of the code > when looking at the source code. (along the same lines of using goto's or > catch/throw to control logic of code would not be a good idea) > > For me, I do not think Dynamics was a good thing to add to Mathematica. > Yes, it has cool side effects, but on the other hand, it makes > programming in Mathematica, when using Dynamics, so much more complex to > understand. > > We have the classic event listener GUI model around which everyone > understood how that works as it is a simple model why make a new one? May > there is some good internal design reasons in Mathematica beyond my > limited > understand of it which beyong the scope of this topic. > > I now have a new measure of what makes a Mathematica expert: You are a > mathematica expert, if you REALLY do understand Dynamics :) > > --Nasser > > > "Murray Eisenberg" <murray at math.umass.edu> wrote in message > news:ht1uua$3cf$1 at smc.vnet.net... >> There IS a "simple" answer. Actually, two answers. it used to be that >> the only way to do this was to use SetDelayed ( :== ) for the symbol you >> wanted to be recalculated whenever you changed another variable whose >> values was specified by Set ( == ). Since Mathematica 6, you also have >> the more sophisticated method of using Dynamic quantities. >> >> (* method 1: use SetDelayed instead of Set for b *) >> a == 5; >> b :== 3 + a >> b >> 8 >> a == Pi; >> b >> 3 + Pi >> >> >> (* method 2: use Dynamic *) >> Clear[a,b] >> Dynamic[a] >> a >> a == 3; (* preceding output changes to 3 *) >> b == 3 + a >> 6 >> a == Pi; >> b >> 3 + Pi >> >> (* method 3: another way to use Dynamic *) >> Clear[a,b] >> a == 3; >> Dynamic[b == 3 + a] >> 6 >> a == Pi; (* preceding ouptput changes to 3 + Pi *) >> b >> 3 + Pi >> >> >> On 5/19/2010 7:01 AM, Victor Roberts wrote: >>> I'm new to Mathematica, so perhaps there is a simple answer >>> to this question. >>> >>> How to I set Mathematica so that when I change the value >>> assigned to a variable it will automatically change all >>> later calculations that use that variable. >>> >>> For example, if I set >>> >>> a == 5 >>> >>> and >>> >>> b == 3 + a >>> >>> I would like the value of b updated each time I change the >>> value of a. >>> >>> Right how, I need to recalculate each and every expression >>> that uses the variable a if I change its value. There must >>> be a better way. >>> >>> >>> -- >>> Vic Roberts >>> Replace xxx with vdr in e-mail address. >>> >> >> -- >> Murray Eisenberg murray at math.umass.edu >> Mathematics & Statistics Dept. >> Lederle Graduate Research Tower phone 413 549-1020 (H) >> University of Massachusetts 413 545-2859 (W) >> 710 North Pleasant Street fax 413 545-1801 >> Amherst, MA 01003-9305

**Some collected information about Dynamic**

**Re: ProgressIndicator inside DynamicModule**

**Re: How to Enable Automatic Recalculation**

**an attempt at solid modeling with Mathematica**