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
The ability to declare a variable as static for a proc etc so global variables don't have to be used and thus stored in the BSS segment affecting efficiency. Closures could be used, at the expense of readability code complexity. Since static-type ability is present in C and C++ (and a closure could be implemented behind the scenes in Javascript if that is needed), if would seem not a great hurdle to add to nim-lang.
Description
This is different from using the global pragma, which is to be avoided to keep the variable out of the BSS segment, which is where globals go.
Alternatives
No response
Examples
proc myCounter(): int =
static var c = 0 # only initialized once
c = c + 1
return c
Backwards Compatibility
No response
Links
No response
The text was updated successfully, but these errors were encountered:
Summary
The ability to declare a variable as static for a proc etc so global variables don't have to be used and thus stored in the BSS segment affecting efficiency. Closures could be used, at the expense of readability code complexity. Since static-type ability is present in C and C++ (and a closure could be implemented behind the scenes in Javascript if that is needed), if would seem not a great hurdle to add to nim-lang.
Description
This is different from using the global pragma, which is to be avoided to keep the variable out of the BSS segment, which is where globals go.
Alternatives
No response
Examples
Backwards Compatibility
No response
Links
No response
The text was updated successfully, but these errors were encountered: