lua-users home
lua-l archive

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



On 04/10/2006, at 6:01 PM, David Olofson wrote:


	procedure do_stuff(y)
	{
		for local x = 1, 10
			for local y = 1, 10
				<stuff>;
	}

This will not compile, as the declaration 'local y' in the inner loop
tries to redeclare the 'y' argument of the procedure. Same thing if x
was declared outside the procedure; it wouldn't compile because
'local x' would be an attempted redeclaration.


However Lua currently allows redefinition, eg.

local y = 1;
f ()  -- uses 1st y
local y = 2;
f () -- uses 2nd y


I'm not sure the the solution doesn't introduce its own problems, possibly numerically as many as the ones it tries to fix.

How about this? Make a "lint" program that detects these things, outside the Lua interpreter itself, which is trying to be small and compact.

- Nick