lua-users home
lua-l archive

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


I would like to suggest a little change to table constructors related to local
variables. Let me explain...

The reference manual says that:
   " The statement
       local function f () ... end

   translates to
       local f; f = function () ... end "

I think that this meaning would be extended to table constructors as well:
   The statement
       local t = { ... }

   translates to
       local t; t = { ... }

This way a statement like
   local t = {f = function() print(t) end}; t.f()

would work as expected. Currently it prints nil (if previously it wasn't given
a value to another variable also called 't'). It seems reasonable that 't'
should be a table (that one which was just created) instead of nil or anything
else.

Differently the statement
   local t; t = {f = function() print(t) end} t.f()

works pretty well! As expected!

Is there some drawback of doing this change?

-- Milano Carvalho

_________________________________________________________________
MSN Messenger: converse com os seus amigos online. http://messenger.msn.com.br