I am trying to work my way through Dynamic but there is something I dont get and I would appreciate very much some clarification. Consider the following code
Manipulate[
var1 = Dynamic@par1;
im1 = Graphics[Circle[], Axes -> True];
locd = Dynamic[locator];
pointOK = Dynamic[locator + {-1, 1}];
pointWRONG = locd + {-1, 1};
Grid[{
{"[1.1]", par1 + 2}
, {"[1.2]", var1 + 2}
, {"[1.3]", Evaluate[var1 + 2]}
, {"[1.4]", ReleaseHold[var1 + 2]}
, {"[2.1]", LocatorPane[locd, im1]}
, {"[2.2]", locd}
, {"[2.3]", pointOK}
, {"[2.4]", pointWRONG}
, {"[2.5]", Graphics[{
PointSize -> Large
, Blue, Point@pointOK
, Red, Point@pointWRONG
}, PlotRange -> 2, Axes -> True]}
}
, Alignment -> Left
]
, {par1, 0, 1}
, {{locator, {0, 0}}, None}
]
For different reasons I would like to have a manipulable parameter par1 and perform some alebraic operations on variables defined on it, like in [1.1] in the picture above. But, if, just out of fun, I declare a symbol var1 = Dynamic@par1 and try to perform some algebra on it, like in [1.2], it does not get evaluated. I read that Dynamic has HoldFirst and I thought that Evaluate would help me, as I tried in [1.3], but without luck. The same for ReleaseHOld, [1.4].
The weird thing for me is now that Point (and surely other functions) is able to evaluate this kind of expressions. Consider the Locator in [2.1] based on the locator control and the symbol locd = Dynamic[locator] now. If I want to some algebra on the momentary values of locator, I have to do it like in the symbol pointOK, [2.3], and NOT as in symbol pointWRONG, [2.4], since the Dynamic object is "added" to each element of the list {-1,1}. Nevertheless, in the last graphic, Point is able to process pointWRONG, otherwise you would not see the 2 red points.
So, what property has Point or what do I need to evaluate expressions containing Dynamic objects (such that, e.g., I get the same in [1.1] and [1.2])? Thank you!
EDIT:
Compared to the question Programming with Dynamic, I think this question deals more with the question on how to evaluate an expression containing a Dynamic object (if Dynamic could not be evaluated numerically, then Point would not be able to display anything, but you can see the points in my plot). In Programming with Dynamic I had the feeling that it was important to understand that the head of Dynamic[x] is Dynamic. But some evaluation has to be possible even if objects like Integer and Dynamic, again, otherwise Graphics@Point@pointWRONG would not work.


Point(and surely other built in functions) to identifyDynamicand evaluate it internally? (see my edit) – Mauricio Fernández Jan 18 '17 at 14:57InputForm@ToBoxes@Graphics@Point@Dynamic@xtake a look. When written to notebook there is noPoint, justBoxes. TheFrontEndcares about rendering them. E.g. thatFrameBoxis a rectangle with a frame. So it cares aboutDynamicit know it has to know its current value for display purposes, and if in GraphicsBox it is interpreted accordingly, but in no case Dynamic evaluates. The FrontEnd just takes the content of Dynamic and evaluates it but as a "separate" evaluation which is a part of rendering process, not the evaluation of the original expression. – Kuba Jan 18 '17 at 15:03