lua-users home
lua-l archive

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



> I guess i was just thinking it would be nice if you could decide for
> yourself if you wanted to allow pre-existing values to be returned or
be
> able to override the value returned at times.  No big deal...

I sometimes wonder why Lua doesn't have __get and __set which are called
every time, rather than the current system.



> I don't see how I can do that with __index or __newindex... looks like
> they would both just silently assign nil and not inform me.  I tried a
> couple permutations but couldn't get it to go.
> 
> Any chance you have the time to give an example?  S'ok if you don't -
> we're all busy folks. :)

You need to use an empty proxy table. The table you set the metamethods
on is empty. The values that you store in the this table are actually
stored elsewhere in another table. That way __index and __newindex get
called every time.

Nick