[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Tue, 25 Mar 2014 06:32:32 +0200
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.
For example, with a simple "list" object:
a = list{1,2,3}
tostring(a) --> "{1,2,3}"
a..4 --> {1,2,3,4}, not "{1,2,3}4"
Having said that, I must admit that I've often wished for a builtin
Lua function that
simply concatenates all its arguments. It's available in the API and the VM, but
not in Lua. That makes it trivial to write in C for oneself, of course.
/* tuple.concat(...) */
static int tuple_concat(lua_State *L) {
lua_concat(L,lua_gettop(L));
return 1;
}
But I find it curious that this powerful Lua feature is not exposed at the level
of the scripting language.
- References:
- [ANN] Lua 5.3.0 (work2) now available, Luiz Henrique de Figueiredo
- Re: [ANN] Lua 5.3.0 (work2) now available, Egor Skriptunoff
- Re: [ANN] Lua 5.3.0 (work2) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work2) now available, Andrew Starks
- Re: [ANN] Lua 5.3.0 (work2) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), katlogic
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Hisham
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Rena
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), William Ahern
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Andrew Starks