lua-users home
lua-l archive

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


Gang, consider this:

"p = {}
t = {
     __index = function(table, key) print("index") end
    }

setmetatable(p, t)"

Now, when I execute these two following lines of lua code:

"q = p.x
p:fn()"

...both end up going through __index in an attempt to look up x and fn in p,
respectively.

I've been trying everything, but haven't figured out a way (if it's possible
at all) to distinguish inside my __index function whether it is being called
via a . (dot) operator or a : (colon) operator.

Is this possible?

Thx,
Ando