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

Feature request: Const declarations in methods and functions #5946

Open
MikaelMayer opened this issue Nov 29, 2024 · 1 comment
Open

Feature request: Const declarations in methods and functions #5946

MikaelMayer opened this issue Nov 29, 2024 · 1 comment

Comments

@MikaelMayer
Copy link
Member

Following the ideas of this video
https://youtu.be/f74PSgwLdDk?si=M5llP57gTIwiw3dA&t=969

We wish to have

method Test() {
  const x := 2;
  x := x + 1; // Error !
}

that could prevent accidental rewrite of a variable, like in JavaScript, or Rust (let without mut)

Similarly, in functions, we could benefit from this syntax and deprecate the "var" there, since variables are not overridable by default.

function Test(): int {
  const x := 2
  x
}

The semi-colon could be optional for functions.

@MikaelMayer
Copy link
Member Author

Related to #5914

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant