lua-users home
lua-l archive

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

On Sep 5, 2013, at 9:40 AM, steve donovan <> wrote:

> On Thu, Sep 5, 2013 at 4:23 PM, Jorge <> wrote:
>> I'll say this: I don't like intensive use of metamethods. It's /perhaps/ ok
>> for really basic __index and __newindex stuff... But anything else confuses
>> me when reading code. I dont't know why, but suspecting there might be some
>> crazy side-effects makes me anxious.
> Well yes, it does raise the 'magic' level of the code.  I stopped
> liking C++ when I realized that _anything_ could happen at any line.
> Life in Lua is better when we can clearly read the intent, so
> metamethods can be abused like operator overloading.  'for k,v in
> pairs(t) .. ' has no magic, 'for v in t' has got magic.  Is the price
> of the magic worth the extra few less keystrokes?  That's a question I
> don't have an answer for - it depends whether I'm a writer or a reader
> ;)

Yeah I'm also on side of "operator overloading considered bad", but the choices of which ones are included in a metatable seems, well, arbitrary.