lua-users home
lua-l archive

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


On Mon, 2002-04-29 at 14:49, Reuben Thomas wrote:
> > 	this is simple is there is no local value then try a global value if
> > there is no global then create a local value.
> 
> But what if you wanted to read an unitialised local?
> 
> e.g.
> 
> while ... do
> 
>   if foo then ...
> 
>   foo = bar ()
> end
> 
> here, I clearly want foo to be local, without declaring it. But you're
> forcing it to be global. That doesn't sound like local by default!
> 

	Only if there is a global named foo. Also you could initialize a local
value with nil before entering the loop like this: 

	foo = nil
	while ... do 
		if foo then ...

		foo = bar ()
	end

	Since foo is local then you are not damaging any value initializing it.
The global one would be unharmed. 

-- 
[]'s Victor Bogado da Silva Lins
victor@visgraf.impa.br