lua-users home
lua-l archive

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

On Wed, Nov 18, 2009 at 12:21 PM, Thomas Lauer <> wrote:
> I've tried to "orthogonalise" the available metamethods. The beauty of
> metamethods is that if you don't want or need them, they are not getting
> in the way, so I reckoned a more rounded spectrum would be helpful for
> some applications.

That seems a most desirable goal. The balance here is 'explainabilty',
e.g. does it significantly complicate any description of table lookup?


quote: "__usedindex behaves exactly like __newindex but when the
indexed key actually exists (value is overwritten). this allows simple
implementation of read-only tables, mirroring C structures etc without
slow/lengthy/fragile table proxying constructs."

So, if you want a read-only table, you make __usedindex always return nil?

This would also be very useful for implementing properties...

steve d.