[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [manual] chaining metamethods
- From: Stephan Hennig <sh-list@...>
- Date: Wed, 27 Jan 2016 20:34:27 +0100
Am 27.01.2016 um 19:27 schrieb Dirk Laurie:
> 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?
Upfront, I didn't mean to say the manual is wrong. I should better have
written "may cause misinterpretation" instead of qualifying it as
"misleading". The former is what I have in mind.
The problem is that it is not strictly clear what "access to metamethod"
means. Does it refer to the retrieval of the metamethod from the
metatable or does it refer to an access to any of the metamethod's elements?
Consider t[1]. Is that an access to t? I'm not a native English
speaker, but if there's any way for the answer to be "yes", the current
description may cause misinterpretation.
Best regards,
Stephan Hennig