[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: Thu, 27 Mar 2014 08:12:27 +0200
2014-03-27 1:26 GMT+02:00 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
>> Why not create such a function as a member of the string library?
>> string.concat( "there ", "I", " would look ",1, "st")
>
> How is that different from just this?
> "there " .. "I" .. " would look ",1 .. "st"
function foo()
return "there ", "I", " would look ",1, "st"
-- a real example would do some work to get there, and would
-- several return statements, not equally many values each time
end
table.concatenate{foo()} -- does not respect metamethods, must
have strings or numbers
string.concat(foo()) -- concatenates respecting metamethods
But calling it string.concat misses my point.
There is no reason for __concat to have anything to do with
strings; on the contrary, I was thinking of its use for lists.
The API function / VM instruction is there. It applies any
right-associative function to values on the stack, provided
thatthe function is supplied as a __concat metamethod.
It is ideal. But it is not accessible from a script.
- References:
- 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
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Dirk Laurie
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Oliver Kroth
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Luiz Henrique de Figueiredo