lua-users home
lua-l archive

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


On Fri, Jun 14, 2019 at 6:43 PM Patrick Donnelly <batrick@batbytes.com> wrote:

> - I think it's really important that "local <toclose> foo, err = bar()" be allowed.

This is probably bikeshedding, but:

local (x scoped), (y const), (z const alias) = a, b, c

Modifiers follow a variable in parentheses, which is both invalid in earlier versions and obvious enough to infer what applies to what, even when multiple modifiers are used.

Note that this syntax does not require the modifiers to be true keywords, they can be contextual keywords that have a special meaning only when following an identifier in such a parenthetical declaration, and can be used as identifiers elsewhere (like, for example, the override specifier in C++). So this, for example:

local (scoped scoped), (const const) = a, b

declares a scoped variable 'scoped' and a const variable 'const'.

I would further allow plain and parenthetical declarations to be mixed together freely, and even omit initialisation:

local (x scoped), y

In this case, 'x' and 'y' are nil-initialised. Even in the current 5.4 alpha, a runtime check is required to enforce the mandatory initialisation rule for <toclose> variables, and nils are explicitly allowed, so there is no functional difference.

Cheers,
V.