If the use of global is discouraged, then it is preferable to remove it completely from the language and use static variables at the package level.
Proposed Solution
Static variables at the package level are safer to use, plus they are declared in a package scope, so there is no collision with other symbols with similar names.
package main
static my_var := 1
fun main() {
my_var += 1
}
To reduce issues with globals, they already behave like static variables.
The keyword should indeed be changed to static plus update of the docs and syntax design document.
Describe the feature
From the documentation:
If the use of
global
is discouraged, then it is preferable to remove it completely from the language and use static variables at the package level.Proposed Solution
Static variables at the package level are safer to use, plus they are declared in a package scope, so there is no collision with other symbols with similar names.
Additional Information
No response