lua-users home
lua-l archive

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


Em sex, 14 de jun de 2019 às 09:52, Paul Ducklin
<pducklin@outlook.com> escreveu:
>
> Then perhaps the issue would better be solved with new keywords rather than trying to add modifiers to “local”. For clarity, I would much prefer to write:
>
> do
>   local a,b,c
>   autoclose e,f,g
>   const t = 2*math.pi
>   ...
> end
>
> to declare what are essentially three very different sorts of local object, rather than denote (using that rather clumsy angle-bracket syntax) that they are all local variables with slightly different flavours.

They are not slightly different flavors, but three different,
additive, concepts indeed.

local Name = value --> lexically scoped Name
local & constant  Name = value -->  local AND constante value for Name
local & caught Name = value  --> local AND to be __caught when out of scope

You can even understand like "local&constant"  or "local&caught" as
qualifiers for Names that can be highlighted (as 'local' is in fact)
by your favorite editor.

> As many have said, the idea of a “constant variable” is kind of weird. And if a to-be-closed variable is such a different sort of beast to a regular local variable that it needs different compile time opcodes, then it doesn’t seem weird to have a unique keyword to declare it. In fact, it feels weird to use the same keyword “local” to declare them all, especially the idea of a “local constant variable”.

<toclose> is ugly, moreover, 'toclose' is not a good word. In fact, we
can make many things with "Name"  when it is out of scope not directly
related with 'close' or 'finalize' anything, which will make 'close'
and 'finalize' - like words very confusing when programmers try to use
__caught to solve other problems.

"constant variable" is a misinterpretation: the 'Name' is 'local',
namely, lexically scoped, AND maybe 'constant' or 'caught'. The
'variable' is only a (common) subtype that is the default for
convenience :)

-- 
Rodrigo Azevedo Moreira da Silva