[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lua.concat (Was: Simulating Lua states in Lua with only 250 lines of code)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sat, 27 Jun 2015 11:31:56 +0200
2015-06-27 10:59 GMT+02:00 Sean Conner <sean@conman.org>:
> It was thus said that the Great Nagaev Boris once stated:
>> On Sat, Jun 27, 2015 at 6:34 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> I've several times asked for access
>> > to lua_concat (which respects __concat), always without success.
>>
>> Would it work like
>>
>> local a = "foo"
>> local b = "bar"
>> local c = debug.lua_concat(2)
>> print(c) --> "foobar"
>> print(a) --> nil?
>> print(b) --> nil?
>>
>> ?
>
> I would think like:
>
> local c = lua.concat("foo","bar","baz","blah")
> print(c) --> "foobarbazblah"
>
> And it's not like the C code to add it would be that hard---a very simple
> implementation (that expect only strings or integers) would be:
>
> int concat(lua_State *L)
> {
> lua_concat(L,lua_gettop(L));
> return 1;
> }
Yes, that is what I intended. I actually have a little C module like that,
which also offers stack manipulation routines like lua_pushvalue,
lua_settop etc for use in tail-call situations. And since writing modules
in the C API does not fill me with religious indignation, I can live with
that.