Coding philosophy : Is using global goto like using a global variable?
이전 댓글 표시
Hi,
Must I considere that using a global goto block in a Simulink model is like defining a global variable in a code?
I dont' talk about the functionnal point of view, but about "coding philosophy".
In several companies I've worked for, I've come across coding rules that recommand to use global variables as less as possible, and more often totally avoid them...
In a code, global variables are shared between functions, while in Simulink, global gotos are shared between subsystems... But subsystems are not "functions"...
So I'm wonder about this "global" Goto option in Simulink... Is it just an "option name" or is there something underlying behind this name?
GL.
채택된 답변
추가 답변 (1개)
Pat Gipper
2021년 2월 10일
1 개 추천
The thing about global visibility is that this signal can be accessible anywhere in the entire model, from sub-system to sub-system, from the top level of the model on down. The signal name cannot be re-used anywhere else in the entire model. This makes it difficult to combine subsystems from multiple designers because of potential signal name duplication.
It is therefore encouraged that you use "local" option to the maximum extent. But local signals are only accessible in From blocks at the same diagram level as the Goto block. This is painful restriction results in the "scoped" option, which allows you to have the From block at lower levels within the same sub-system. But the one drawback is that you are forced to also include a "Goto Tag Visibility" block at the top subsystem where the signal is going to be used.
카테고리
도움말 센터 및 File Exchange에서 Subsystems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!