lua-users home
lua-l archive

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


It was thus said that the Great Steven Degutis once stated:
> I am perhaps unique in this situation, but I'll share my opinion anyway:
> 
> Personally, I do not use most of the metamethods. In fact, I strongly
> recommend against them to users of my application, and authors of
> third party extensions for my application. The only two I ever use are
> __gc for userdata, and __index in the simple example of foo.__index =
> foo and setmetatable({}, foo). I find everything else to not only be
> unnecessary, but sometimes even prohibitive.

  Are you talking about using metatables with tables?  

  I don't set metatables in tables, but I do use metatables on userdata, and
I almost always set __tostring (so I get something more useful than
"userdata (0x2342342342)"), __gc, __index and __newindex.  There's one case
where I've set __eq, __lt, __le and __len (userdata wrapping over struct
sockaddr) and another case where I set __add, __sub and __umn (POSIX signal
sets) and there, I'm still deciding if that's useful or cute.

  -spc