lua-users home
lua-l archive

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


> On Jan 4, 2015, at 2:21 AM, Lorenzo Donati <lorenzodonatibz@tiscali.it> wrote:
> 
> A detailed list of events controlled by metatables is given next. Each
> operation is identified by its corresponding **event name**. The **key
> for each event** is a string with **its name prefixed by two
> underscores, '__'**; for instance, the key for operation "add" is the
> string "__add". Note that queries for metamethods are always raw; the
> access to a metamethod does not invoke other metamethods. You can
> emulate how Lua queries a metamethod for an object obj with the
> following code:
> 
>     rawget(getmetatable(obj) or {}, event_name)
> 
> in this latter Lua code line the 2nd argument apparently refers to the
> /name/ of the event, but it should refer to the associated /key/.
> It could seem nitpicking, but the cited paragraph is very precise and
> seem to stress the difference quite a bit. Therefore that 2nd argument
> could confound the newbie reader, especially if he has paid due
> attention to the previous lines.
> 

Yes, I think you are right, it should either be / key_name / or / “__” .. event_name / in the pseudo-code. As written it is wrong based on the prior paragraph.

—Tim