lua-users home
lua-l archive

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


2016-07-21 20:12 GMT+02:00 Martin <eden_martin_fuhrspam@gmx.de>:
> 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.

There are two extremal kinds of Lua programmer.

One kind writes beautiful modules and puts them on Luarocks. These
programmers should write programs that look and feel like good Lua
because their users are Lua programmers.

The other kind writes programs that do a particular task. These programs
have a user interface such that the user may not even know that it is
a Lus program that does the work. The user interface looks and feels
like whatever is good for the application.

I'm halfway in between. I write programs whose user interface is actually
the Lua interpreter, but metatabled until it looks and feels like the
application. The user does not need to know any Lua, but when I work
on the program, all of Lua is available to me.

Why do I do this? Because I can.