lua-users home
lua-l archive

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


Hello.

I wonder if this is okay for local const variables to be shadowed?

Consider these examples:

1) shadow local const variable with another value:
local x <const> = 123
local x = 456
print(x)

2) shadow local const variable with another local const variable:
local x <const> = 123
local x <const> = 456
print(x)

3) both close metamethods will be called eventually:
local x <close> = setmetatable({}, {
__close = function () print("closed 1") end
})
local x <close> = setmetatable({}, {
__close = function () print("closed 2") end
})
local x = 123
print(x)