proposal: spec: init-only package level variables #20598
Labels
LanguageChange
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Proposal
v2
A language change or incompatible library change
Milestone
Mutable state held in package-level variables can be problematic for a few reasons, e.g. concurrency [edited to remove erroneous mention of multiple imports]
It would be useful to be able to declare a form of "assign-once" variable that can only have its value set via an initializer in the declaration or in a subsequent init function. Once all init functions have completed the value of the variable cannot be changed.
Some other languages use a special keyword to indicate this type of variable (e.g. pony uses let for assign-once variables and var for others)
The text was updated successfully, but these errors were encountered: