Could someone please explain the following behaviors?
I don't know if it's related to TrackedSymbols, assignment, evaluation of rhs of assignment, or initialization in DynamicModule.
DynamicModule[{x, y},
Column[{
Slider[Dynamic[x]],
Dynamic[Refresh[y = x, TrackedSymbols -> {y}]],
Dynamic[y]
}]]
Without the initilization of x and y, only the 2nd Dynamic updates.
And, if y=x is changed to y=x+1, neither Dynamic updates;
y=x++, or RandomReal[], which of course makes Slider pointless, both Dynamic update.
Now if I change the initilization part to e.g. x=0,y=0,
then in the case of y=x, y=x+1, y=x++, neither Dynamic updates;
only those with y=RandomReal[] updates.
I don't know if the above is useful in real life. I just create them to understand better the behavior Refresh wrapped in Dynamic and if it's OK/meaningful to use assignment in Refresh.
Thanks a lot.
=================================
I put my newest questions here for better readability.
I'd like ask regarding #4 of the generic situation.
Q1: Is my understanding correct? when Dynamic@Refresh runs for the 1st time, y's state is changed from no_initial value to y=0, which is passed by x via assignment.
Q1-1: And when y is provided an initial value of 0, in the case of y=x++, y's state doesn't change, when Dynamic@Refresh runs for the 1st time, and therefore, it doesn't run into Infinity, unless use ++x, as you suggested.
Q2: When I drag the slider thumb, why the newest value of x can't be passed to y via assignment? Is it because I set explicit trackedsymbol to {y}. This part is still quite confusing for me. (The situation with x++ or RandomReal[] isn't the same as y=x+1, since neither of them is related to slider).
0and yes all those updates are triggered by theDynamic[Refresh[.., slider here should have no influence. – Kuba Apr 30 '17 at 14:34(y=x)? If not so, how comex++works, which, I think, is also passing x's value to y ? Thanks again. – Bemtevi77 Apr 30 '17 at 16:05y = x++is run fromDynami[Refresh[, it changesyvalue soRefreshis triggered again. Whenxis changed via Slider then onlyxis changed.y=xdoes not care. Don't be sorry, I'm not the best in explaining stuff :) – Kuba Apr 30 '17 at 16:08x++works because the change of x value occurs withinDynamic[Refresh[; it has nothing to do withSlider. 2. There isn't any communication betweenSlider[Dynamic[andDynamic[Refresh[, even though both containx? If so, is this due to the HoldFirst attribute of Dynamic or some other reason ? – Bemtevi77 Apr 30 '17 at 16:27DynamicModule[{x = 0, y = 0}, Dynamic[Refresh[y = ++x, TrackedSymbols -> {y}]]], where y updates toInfinity. I found if the rule is changed to a delayed rule:>, y stops at 1. Could you please have a look ? – Bemtevi77 Apr 30 '17 at 16:58TrackedSymbolsshould always be used with:>, otherwise it will get evaluated. In you case it didn't matter because they are inRefresh, which is the first argument inDynamic, which is held. Should have write more about that. – Kuba Apr 30 '17 at 18:38