lua-users home
lua-l archive

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


It was thus said that the Great Viacheslav Usov once stated:
> I would guess this must have been discussed, so pointers to prior
> discussions will be appreciated.
> 
> Still: what speaks against implementing a new Lua compilation mode where
> everything must be explicitly declared to be either local or global, and
> anything not so declared would result in a compilation error?

  The major stumbling block I see is how to declare globals.  There already
exists explicit syntax to declare locals but no explicit syntax to declare
globals.  Things like "strict.lua" exist to hack around this limitation, and
some might say this does exactly what you want (or close enough to it).

  Something else that speaks out against this:  a change in syntax, either a
new keyword, which may clash with existing code or operator,which can cause
problems in compiling code that doesn't understand it---I have had this
issue with multi version code:

	if _VERSION == "Lua 5.3" then
	  function bor(a,b) return a | b end
	elseif _VERSION == "Lua 5.2" then
	  bor = bit32.bor
	else
	  function bor(a,b) return a + b end
	end

won't work as intended in Lua 5.1 or 5.2 because of the new | operator in
Lua 5.3.  This may not be an issue for you, but for other people, it may be.

  -spc