lua-users home
lua-l archive

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


This should be how all attributes are specified imo. +1

On Tue, 8 Oct 2019, 11:11 Fangrui Song, <i@maskray.me> wrote:
> 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   =