lua-users home
lua-l archive

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


2012/11/6 spir <denis.spir@gmail.com>:

> I'm aware of the issues of table output (including serialisation) and am not
> advocating here for a universal tostring; this is a distinct issue. I just
> wish a tag for invocation of tostring, _provided_ tostring is defined. It's
> up to the programmer to do the job. In the present state of things, as far
> as I know, even when the job is done and there is a tostring for a given
> kind of data, it is not called; i mean, it not called by format, unlike when
> print alone is used.
> (I'm really fed up of calling tostring on about everything I need feedback
> about... feels like prehistoric programming compared to the agility and
> flexibility Lua provides.)

I posted a patch to the Lua 5.2 table library on 26 July 2012.
All it does is to make string.concat call a __concat metamethod
if one is defined. Your Lua program can then give strings a __concat
metamethod that calls tostring on the operands.

The thread was called "tab;e.concat and metamethods".