I'm worried about the use of persistent variables in Dynare. In several instances, they are only re-initialized if the variable is empty, meaning the first time that the function is used at the beginning of a session or after "clear all"
This behavior is wrong if the function with persistent variables is used twice in different contexts in the same *.mod file (identification_analysis and estimation, for example, or two successive estimations). Also, it creates hard to understand errors when debugging with option noclearall
Because, the initialization must sometimes take place far away from the function itself, it is even hard to check whether there is proper initialization or not.
I suggest 1) to unify the interface to initialize the persistent variables: either passing additional arguments, or calling the function without any input arguments 2) write in the header of a function using persistent variable which functions are calling it and where initialization takes place. 3) See if using classes with could avoid the use of persistent variables
What do you think?
Best
Michel