Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make variable declarations immutable by default #51

Open
liquidev opened this issue Mar 28, 2022 · 0 comments
Open

Make variable declarations immutable by default #51

liquidev opened this issue Mar 28, 2022 · 0 comments
Labels
enhancement New feature or request language feature

Comments

@liquidev
Copy link
Member

liquidev commented Mar 28, 2022

Currently it's easy to overwrite existing variables by accident, due to all assignments mutating the outermost variable. Instead of this, I think that by default creating a new variable each time would make more sense, with an optional mut keyword that makes a variable mutable, and prevents further declarations from shadowing existing ones:

x = 1
do
  x = 2
  assert(x == 2)
end
assert(x == 1)

mut i = 1
while i <= 10 do
  i = i + 1
end
@liquidev liquidev added the enhancement New feature or request label Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request language feature
Projects
Status: 📦 Backlog
Development

No branches or pull requests

1 participant