2 edited tags
| link
source | link

ControlType -> None Vs. Module inside Manipulate (i.e. making everything local)

I'm building a program on another one made available in the Wolfram Demonstration Project.

I've noticed that in the original code (working flawlessly) many variables were made local inside the Manipulate wrapper by making ghost controls, i.e.

{var1, ControlType -> None}
{var2, ControlType -> None}
{var3, ControlType -> None}...

and there was no Module instruction inside the Manipulate.

I also found out that, after some changes made by me, the code wasn't anymore behaving well and that the main body of the manipulate command was executed two times after changing a control value.

By trial and error I managed to fix that double execution by inserting a Module command encapsulating a new variable created by me (causing the problem), that was global and that re-triggered the evaluation of the Manipulate body section.

I've read elsewhere that making all variables local inside a Manipulate can be a good programming practice and that guideline actually helped me to pinpoint the problem and avoid the double evaluation issue.

The whole code is too complex and long to be posted here and also to be reduced to a stripped down example.

So my questions are rather theoretical but probably clear enough in their essence to be answered by some Mathematica user more expert than me.

They are:

1) What's the difference (if any) between using a Module or using the ControlType -> None technique?

2) I've some compiled functions inside the Initialization section of the Manipulate. I see that those compiled functions are global and I don't know how to make them local. Do I have to leave them global without worrying much (there's no apparent issue about them till now) or is it advisable to make them local somehow (if so, how)?