Manipulate doesn't always evaluate in the order I expect it to. What is the evaluation sequence for Manipulate and other functions involved with the front end? I have seen the evaluation sequence for kernel only functions, but that was for a reference for Mathematica 3, and doesn't deal with the front end.
Asked
Active
Viewed 703 times
12
-
1Can you provide an example of Manipulate not evaluating in a certain sequence? – Mike Bailey Jan 18 '12 at 05:50
-
Using the initialization option, it will evaluate the variables for the controls, then the initialization and then the content. The question is more focused on what is the actual evaluation sequence though. – insect Jan 18 '12 at 05:55
-
Well you seem to have answered your own question then. – Mike Bailey Jan 18 '12 at 05:56
-
Not quite what I was hoping for. I'll see if I can find the one for the kernel tomorrow to better explain. – insect Jan 18 '12 at 06:04
-
I'd love to help more, I'm just curious as to what you're expecting. If you give us an example we can maybe piece together why it evaluates in the order it does. – Mike Bailey Jan 18 '12 at 06:06
-
1This SO post (especially the answers) might be useful here: Print Dynamic variable inside DynamicModule – István Zachar Jan 18 '12 at 12:16
1 Answers
10
According to my previous experiences and this post, the sequence goes like this (please feel free to correct me in this post):
From the documentation:
Manipulategenerates aDynamicModuleobject, with the variablesu,v, etc. specified as local.That is, first Manipulate wraps its result into
DynamicModule, then...- ...gives unique names to local variables (as it is a scoping construct).
- Next, the body of
Manipulateis evaluated in standard order. - The output cell is created by evaluating the result of the
DynamicModule(or theManipulate). - If there was any
Initialization :> initinsideManipulate, it is now evaluated "when the result is first displayed in a particular session". - If there is any
Deinitialization :> deinitinsideManipulateand the dynamic output cannot be displayed any more,deinitis evaluated.
Contraintuitively, Initialization is called almost ultimately which caused me some frustration over time.
To understand how to load a package with your dynamic content by Needs, see my answer here.
István Zachar
- 47,032
- 20
- 143
- 291