lua-users home
lua-l archive

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


> For instance, what would be the result of "f(x)[1] = 1" (assuming that
f(x) did 
> not return a table)?


The result will be that you create an anonymouse table value {1=1}. Which is
what I would expect. 

Ofcourse, if you expect a table from the function, suppose f(x)=_G, but get
an other type, you could be wondering where your index assignments have gone
(referring to Thomas Lauers comment). But these kind of assumptions are not
good practise anyway (you get runtime errors instead).

However, I agree this might have some other (ugly) repercussions not
immediately obvious at this moment. 

(In fact, to implement this behavior, I would have to change the __newindex
methods of the nil, number, string, etc  matetable (can only in c), right?
Not that I will do that - just for the idea.)


Markus