Slider[] and Dynamic[] implementation details
- To: mathgroup at smc.vnet.net
- Subject: [mg83866] Slider[] and Dynamic[] implementation details
- From: "Otto Murphy" <freefall at stanford.edu>
- Date: Mon, 3 Dec 2007 05:42:37 -0500 (EST)
Hey all, I'm curious about the workings of Mathematica 6's dynamic functionality. Specifically the interaction between Slider[] and Dynamic[] in this simple example: Slider[Dynamic[x, (x = 1 - #) &]] Dynamic[x] Okay so my first question involves removing the first embedded dynamic and leaving just the x, like so: Slider[x] Dynamic[x] Intuitively, to me, the slider function should still be able to update the value of x and the dynamic should still be able to display those updated values. Like if slider were just like a normal function that updates the value of x in the kernel just like a new assignment statement would. BUT, this doesn't happen--X doesn't change. This makes me think there's some special mechanism here. Could someone explain it? My second question has to do with the second argument to Dynamic. Again, intuitively, to me, it seems like when dynamic looks for an updated value of x, it uses that function to assign it it's new value. But this couldn't be completely true because it doesn't work like this: Slider[Dynamic[x]] Dynamic[Dynamic[x, (x = 1 - #) &]] The dynamic display of x doesn't seem to use the function--it only works when it's in slider[]. Why is that? I looked through the documentation and didn't see anything addressing these kinda picky questions, but I'm just darn curious. Although Mathematica isn't open source, I'm assuming there are plenty of people out there who are familiar with implementation details like these. Thanks a lot for the help!