lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo wrote:
> >function Person:fullName() 
> >  return title.." "..firstName.." "..lastName 
> >end 
>  
> I don't see how tag methods for locals would help here: title, firstName, 
> lastName would be parsed as *global* variables. 
> You'd have to declare them as local, but in this case, why not write 
>  local title, firstName, lastName = self.title, self.firstName, self.lastName 

Sorry, I should have been clearer - by "looks up local variables",  I meant a lookups any variable reference in a function, not just variables declared as local.

So if you wanted to look up variables like this:
1. in the locals (I'm assuming arguments are locals too)
2. then in self table (if there is a local self variable)
3. then in the globals table

Is there an easy way to implement this in Lua?

If there we some sort of abstract table that lua put arguments and locals in while executing a function that it did variable lookups on, then a index tag on this table would do the trick.

Steve