lua-users home
lua-l archive

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


On Sat, Dec 6, 2008 at 10:25 AM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
<snip>
>
> Ignacio has spotted that. I hope the version below fixes all this...
> (I really should not debug my code in public like that :-)
>
> static int unrope (lua_State *L) {
>  luaL_Buffer b;
>  luaL_checktype(L,1,LUA_TTABLE);
>  lua_settop(L,2);
>  if (lua_isnil(L,2)) {lua_pushliteral(L,""); lua_replace(L,2);}
>  else luaL_checkstring(L,2);
>  lua_insert(L,1);
>  luaL_checkstack(L,MAXLEVEL-1+LUA_MINSTACK,"cannot grow stack");
>  lua_settop(L,MAXLEVEL+1);
>  luaL_buffinit(L,&b);
>  doconcat(L,&b,2,0);
>  luaL_pushresult(&b);
>  return 1;
> }
>
> Anyway, the point of the code was to promote unrope. But perhaps the bad code
> has given unrope a bad name! (I hope not because ropes are nice and easy to
> build and use in Lua; unrope was just meant as an efficient concat for ropes,
> though it is a bit tricky to get right...)
>
> Thanks for all the feedback.
>

i wonder if it would be appropriate to make table.concat() be unrope().


-- 
hiposon