You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently functions have unfettered access to variables in higher scopes - be it the program's globals, or the caller's variables. This is a really stupid design decision that should be changed.
Proposed solution:
Limit functions to accessing only their local variables (and args/statics)
To use global variables, one must explicitly declare their use with !global $varname
The construct should probably be limited to the function's top-level scope (can't be put inside !if or loops)
Things to consider:
Should !global $var and !global &var be equivalent, or should the first one create a copy of the global variable in local scope (instead of adding a reference)?
What should happen when a function calls !global &var and &var hasn't been yet set?
The text was updated successfully, but these errors were encountered:
Partially done in ad7d725. Currently there is no difference between !global $var and !global &var. The construct can be used inside !if and loops to make it consistent with !static.
Currently functions have unfettered access to variables in higher scopes - be it the program's globals, or the caller's variables. This is a really stupid design decision that should be changed.
Proposed solution:
!global $varname
!if
or loops)Things to consider:
!global $var
and!global &var
be equivalent, or should the first one create a copy of the global variable in local scope (instead of adding a reference)?!global &var
and&var
hasn't been yet set?The text was updated successfully, but these errors were encountered: