lua-users home
lua-l archive

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

On Thu, Sep 24, 2015 at 9:11 AM, Luiz Henrique de Figueiredo <> wrote:
This already does exactly what you want.
Bottom line: there isn't a problem that needs to be solved by adding a syntax
for constants. The parser might be smart and use the constant's index instead
of the local's index, but they are both just an array access in the VM.

A local has different semantics than a true const, though; a local can be reassigned, whereas a name is bound immutably for the lifetime of the reference, for a const. It represents a compiler-enforced safeguard against certain kinds of bugs, and adds meta-semantic information about programmer intention for subsequent readers of your code.

I'll let y'all decide if those are worth the effort and added complexity of extending the core language, but a "smart enough" compiler doesn't provide some of the user-facing benefits as true constants.

Brigham Toskin