dart-lang / dart-lang/language
Variable declaration to be 'final' by default
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
I have observed that in my code the most variables I declare are 'final' and rarely I use some 'non final' variable declaration.
`final int id = 1;`
`id = 2 // The final variable 'id' can only be set once.`
I would propose the variables in Dart to be final by default without the keyword 'final' before the type of variable. This would save some typing.
`int id = 1;`
`id = 2 // The final variable 'id' can only be set once.`
It could be introduced the keyword 'mutable' to declare a non-final variable
`mutable int id = 1;`
`id = 2 // Accepted`
Contributor guide
Research direction
No files, tests, or entry points are named. Start by reading the issue and its discussion to determine the language-design scope; done would require a documented decision on the proposed default variable mutability and syntax.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100