lua-users home
lua-l archive

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


On Mon, Aug 10, 2009 at 4:16 PM, Joshua Haberman wrote:
> The idea is this: you define your structure type as a protocol buffer
> type. .... you could write this in a .lua file:
>
> Alice = upb.new_type("
>  message Alice {
>    optional int32 x = 1;
>    optional int32 y = 2;
>  }
> ")
>...
> - instances of Alice have a more efficient representation in memory.
>  Since the set of all possible fields is known, it can be stored
>  as an array with known offsets for each member instead of as a
>  table keyed by "x" and "y".

That's interesting.  A similar type of thing might be done using one
of the struct libs [1].

> my library is currently ~2300 sloc of C, and compiles to <30kb of object
> code on x86.  You can check it out here (the Lua parts aren't written
> yet):

I had tried protocol buffers before, but it seemed somewhat bulky for
what it did (added 1 MB to the binary I think).  It looks like they
may now have a new "lite" version [2] that much improves this.

[1] http://lua-users.org/wiki/LibrariesAndBindings
[2] http://groups.google.com/group/protobuf/browse_thread/thread/a7f55a418085eaed/19e95baa9dfa5526