OK, we will do this on all our parallel functions .... best Marco
Michel Juillard wrote:
OK, but I suggest that for the time being we refrain from using struct2local
Cheers
Michel
Marco Ratto wrote:
Thanks a lot for checking. I noted for some other routine that when the variable is not explicitly defined in the function, the precedence rule is not followed. It may be also worth trying to find a way to have this precedence rule with assign in
best Marco
Sébastien Villemot wrote:
Le samedi 10 avril 2010 à 11:39 +0200, Michel Juillard a écrit :
As illustrated with the 2 functions attached, if one of the fieldname is also the name of a function present in the path, an 'if' statement calls the function instead of the local variable.
This is in contradiction with the priorities for searching symbol names stated by Matlab documentation and it looks like a Matlab bug, maybe it affects only R2010a, but I didn't get a chance to try with other Matlab versions.
I can reproduce the problem on MATLAB 7.0, 7.4 and 7.9. So this is not specific to one version.
This behavior seems indeed in contradiction with the precedence rules: http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f10-60956....
Note that if we define "run_smoother=1" directly in the file test_s2l.m, then the "if" statement uses the local variable and not the function: in that case the precedence rules are correctly applied.
So it looks like the precedence rules are not respected only when the variable is assigned via "assignin('caller'...)" (as it is in struct2local.m).
This is very strange, it looks like a bug, but since it is present in many versions of MATLAB, we must take it as normal behavior of MATLAB.
Dev mailing list Dev@dynare.org https://www.dynare.org/cgi-bin/mailman/listinfo/dev