Suggestion about metamethods respected by the table library.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Suggestion about metamethods respected by the table library.

Egor Skriptunoff-2
Hi!

Taking into account the fact that since Lua 5.3 the "table" library respects some metamethods, it seems quite illogical that "table.concat()" does not honor "__tostring" metamethod to correctly display tables containing any objects, not only strings and numbers.

-- Egor
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion about metamethods respected by the table library.

Andrew Starks-2

On Mon, Mar 21, 2016 at 09:51 Egor Skriptunoff <[hidden email]> wrote:
Hi!

Taking into account the fact that since Lua 5.3 the "table" library respects some metamethods, it seems quite illogical that "table.concat()" does not honor "__tostring" metamethod to correctly display tables containing any objects, not only strings and numbers.

-- Egor


I might be missing something but `__tostring` relates to `tostring(t)` and `__concat` is related to `t1 .. t2`

Maybe you have something in mind that I'm missing.
Reply | Threaded
Open this post in threaded view
|

Re: Suggestion about metamethods respected by the table library.

Dirk Laurie-2
In reply to this post by Egor Skriptunoff-2
2016-03-21 16:51 GMT+02:00 Egor Skriptunoff <[hidden email]>:

> Taking into account the fact that since Lua 5.3 the "table" library respects
> some metamethods, it seems quite illogical that "table.concat()" does not
> honor "__tostring" metamethod to correctly display tables containing any
> objects, not only strings and numbers.

http://lua-users.org/lists/lua-l/2012-06/msg00733.html

and follow-ups