lua-users home
lua-l archive

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

ср, 3 июл. 2019 г. в 23:16, Egor Skriptunoff <>:
> On Wed, Jul 3, 2019 at 10:56 AM Dirk Laurie wrote:
>> > We have much bigger problem in Lua: every typo in a local variable's name silently converts it to global.

> The typo-in-locals problem could be solved only by an external parser/analyzer (luacheck?).

If we would have pure function declaration this problem causes less pain.
Pure function like ordinary function but isolated from global and
up-values. And all variable must be decelerated explicit or
compilation fails.
local U="up-value"
pure_function fn(print)
  local L
  print(G) -- compile error undeclared G
  print(U) -- compile error undeclared U
  L2=L -- compile error undeclared L2