lua-users home
lua-l archive

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


On Friday 31 August 2007, Chris Swetenham wrote:
> I've thought about this a few times - are there any common or useful use
> cases of metatables where the assumption that metatable functions are
> idempotent (that is, the program state is the same after calling the
> function once as it is after calling it twice), AND that they only modify
> the table they are associated with, would lead to incorrect semantics?
>
> An obvious and trivial example is a metatable that counts accesses to a
> table, but this would usually be used for debugging/profiling rather than
> in production; I've not been able to think of any other examples.

any kind of proxy table.

the table associated with the functions isn't (usually) modified, but the 
underlying (hidden) table is.

-- 
Javier

Attachment: pgpM8_j9SbmNv.pgp
Description: PGP signature