lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


3.3.7 – Local Declarations
...
There are two possible attributes: const, which declares a constant variable, that is, a variable that cannot be assigned to after its initialization; ...

local var <const> = whatever

Constant variables help reasoning about the code, but I think the
current syntax is a bit verbose, and may limit its adoption.
A concise syntax that declares the const property may ease its adoption. For
example: `const var = whatever`


Some languages that make declarations of constant variables simple:

OCaml: let foo =     vs    let mut foo =
Scala: val foo =     vs    var foo     =
Rust:  let x   =     vs    let mut x   =