lua-users home
lua-l archive

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


The subject: is a good question.  I don't believe it's an event
handler similar to __gc etc.  After revisiting the subject in the
manual it's not clear to me what __metatable is for either, except
that it appears to be some kind of user-settable shadow-metatable.

The manual suggests that getmetatable() will return this shadow
metatable in preference to the real one, and that it's an error
to setmetatable() on a table whose existing metatable contains
a __metatable field (whew!) but the actual purpose and semantics
(with regards to metamethods) of __metatable aren't defined at all.

(I think it's safe to not worry about it, until someone wants
to make the purpose of __metatable clear -- I'm doing lots
of fun and wacky things with metatables and I've not needed
to care about __metatable so far.)

--Adam
--
Adam D. Moss   . ,,^^   adam@gimp.org   http://www.foxbox.org/   co:3
"When I was young, I would break down and cry whenever mom made me
throw an empty toilet paper tube in the trash can. I just imagined
it sitting at the dump, all cardboard and sad." -- T.Farnon