[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Strict typing and Lua [Forked From: Re: Are automatic coercions ever going away?]
- From: Sean Conner <sean@...>
- Date: Fri, 1 Aug 2014 20:47:53 -0400
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