lua-users home
lua-l archive

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


On Mar 24, 2014, at 9:32 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:

> 2014-03-25 5:13 GMT+02:00 Andrew Starks <andrew.starks@trms.com>:
> 
>> I also agree that ".." should always call __tostring, even on (especially) tables.
> 
> I don't agree. Lua should "not know what to do" so that a metamethod will be
> looked for. Otherwise we can chuck away the __concat metamethod.
> 

I agree, and your example highlights the deeper difference between operator metamethods and coercion metamethods. I’d hate to see Lua ending up as messy as C++ where figuring out which function was called involves looking at templates, signatures, automatic casts etc etc .. (shudders).

I think __tostring() should get invoked ONLY when tostring() is explicitly called.

—Tim