lua-users home
lua-l archive

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


On 16-07-21 12:17 AM, Dirk Laurie wrote:
> I like having the metamethods available for objects and strings.
> For example,
>
>     animal =  'pig' | 'dog' | 'cat'
>
> can be defined to mean what you can see it should mean, wheres
> using a Lua 5.2 arithmetic operator would produce a 'wat?' feeling.

This produces 'wat?' feeling for me too. If it's not ABNF rule but lua
code. To understand I have to find place where __bor metamethod is
introduced and what exactly it do.

With metamethods you can no longer be sure even what such code is doing:
"person.name = 'Adam'" because there may be __newindex method.