lua-users home
lua-l archive

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


Hi Alexander,

Thanks for the nice reply. Luabins is doing pretty much what msgpack does. Except msgpack is an open format that is supported by other languages (which enables my lua scripts to talk with Ruby through the network). This is also why it is ok to not fully support Lua tables: the goal is not serialization but communication (eventually with other languages not supporting Lua table semantics).

As for the speed question, I don't know if it's good or bad, I'm learning...

Gaspard

On Sun, Jan 2, 2011 at 3:33 PM, Alexander Gladysh <agladysh@gmail.com> wrote:
On Fri, Dec 31, 2010 at 18:07, Gaspard Bucher <gaspard@teti.ch> wrote:
> I understand your point. I am not saying a table in Lua is this or that and
> I agree that it I have to use an arbitrary rule. I am currently using "no
> value in array" means hash:

> if (lua_objlen(L, index) > 0)
>   pack_as_array(L, index);
> else
>   pack_as_hash(L, index);

This would not work. This table layout is a common idiom:

{
 "alpha";
 "beta";
 gamma = "delta";
}

> I am also wondering if there is a faster method to get the hash size (needed
> to prepare the map):
> for(lua_pushnil(L); lua_next(L, index) != 0; lua_pop(L, 1)) ++sz;

That bad?

I'm not familiar with msgpack or zeroMQ, but this may (or may not) be helpful:

https://github.com/agladysh/luabins/blob/master/src/save.c#L29

Alexander.