lua-users home
lua-l archive

Re: [manual] chaining metamethods

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


2016年01月27日 19:04 GMT+02:00 Stephan Hennig <sh-list@posteo.net>:
> Note that queries for metamethods are always raw; when
> looking-up metamethods, Lua doesn't consider a metatable's
> metatable. Lua considers metatables of metamethods, though.
> In fact, chaining metamethods is at the heart of many
> approaches to object-oriented programming in Lua.
Sorry, I find this more obscure than the original one-sentence
description.
> Note that queries for metamethods are always raw; the access
> to a metamethod does not invoke other metamethods.
I read this as "if the metatable does not contain for example
__add, the __index metamethod is not invoked to find
a fallback, eic." What other way is there of reading it?

AltStyle によって変換されたページ (->オリジナル) /