A forum for Spin users
You are not logged in.
Hello,
I have the following structure:
inline foo(parameter) {
d_step {
struct_type struct_local_var;
<code block that is the only one using struct_local_var>
}
}
To safe some memory, I wanted to switch to
hidden struct_type struct_local_var;
However, I get the error message
spin: ./foo.pml:29, Error: cannot hide non-globals (_12_5_6_8_struct_local_var)
What is a "non_global", and why is struct_local_var one? How can I enable hiding struct_local_var?
Best
David
Offline
Any variable is either global or local. So, a non-global means a local variable.
A variable is global if declared outside all proctypes.
An inline can only be inlined inside a proctype, so anything declared inside an inline
is automatically classified as a local variable.
Offline
Thank you for this concise explanation.
Too bad that local variables cannot be hidden. Do they not contribute just like global variables to the state vector?
Since I prefer smallest possible scopes, my variables that are solely used inside one d_step are always local and hence not hideable. Could this be changed in Spin? That would be awesome, because I have many of those variables.
Otherwise, what are the disadvantages if I make such a variable global just for the purpose of hiding it? Since it is hidden, turning it global will not deteriorate POR, will it?
Thanks,
David
Offline
Good point, but if you make sure that the temporary variable (e.g., used only inside a d_step)
is reset to 0 before the d_step returns, then its value will not contribute to the state vector.
So in that case it's similar to being "hidden" -- it's always zero where it is visible to Spin.
Offline