Re: Dynamic: feature?
- To: mathgroup at smc.vnet.net
- Subject: [mg88112] Re: Dynamic: feature?
- From: Chris Osborn <chrisosb at gmail.com>
- Date: Fri, 25 Apr 2008 05:27:59 -0400 (EDT)
- References: <firstname.lastname@example.org>
On Apr 24, 5:06 am, John Fultz <jfu... at wolfram.com> wrote: > On Wed, 23 Apr 2008 04:10:12 -0400 (EDT), Jean-Marc Gulliet wrote: > > Chris Osborn wrote: > > >> I have a cell containing this: > > >> Dynamic[f[a, b]] > > >> Then I do this: > > >> a /: f[a, b] = 12 > > >> and the dynamic cell updates to 12, as I would expect. > > >> When I do this: > > >> b /: f[a, b] = 45 > > >> The dynamic cell does *not* update for some reason. > >> It seems as though it does not realize an update has occurred when it > >> is associated with b. > > >> Does anyone know why this is? > > >> Thanks in advance, > >> Chris > > > Weird. I witness the same behavior if the cells are evaluated in the > > given order. However, ff one change the order of the assignments (i.e. b > > first, then a) Dynamic works as expected. Evaluating the following > > expressions in that order, > > > Dynamic[f[a, b]] > > (* The first output cell is: f[a, b] *) > > > b /: f[a, b] = 45 > > (* The first output cell is now: 45 *) > > > a /: f[a, b] = 12 > > (* The first output cell is now: 12 *) > > > $Version => "6.0 for Mac OS X x86 (64-bit) (February 7, 2008)" > > > I have also recorded the sessions in a PDF file. See > > >http://homepages.nyu.edu/~jmg336/mathematica/weirddynamic.pdf > > > Regards, > > -- Jean-Marc > > A principle rule of debugging Dynamics...consider what Shift-Enter evaluations > do. In this case, exactly the same thing. In fact, Dynamic correctly reflects > what a Shift-Enter evaluation on f[a,b] would do at that very moment. > > Sincerely, > > John Fultz > jfu... at wolfram.com > User Interface Group > Wolfram Research, Inc. Thanks to everyone for their comments; they have been quite helpful. It seems that I was creating two separate rules, one associated with a and one associated with b (I had expected the 2nd one to overwrite the 1st). Because a is the first argument, its rule takes precedence. Thanks also John for the tip on debugging Dynamic -- see what shift- enter does. Chris