lua-users home
lua-l archive

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


On Sun, Oct 3, 2010 at 00:07, Matthew Wild <mwild1@gmail.com> wrote:
> On 2 October 2010 20:54, Alexander Gladysh <agladysh@gmail.com> wrote:
>> On Sat, Oct 2, 2010 at 11:33, Petr Štetiar <ynezz@true.cz> wrote:
>>> John Passaniti <john@japanisshinto.com> [2010-10-01 14:53:18]:

>>> It's a shame, you couldn't use Lua directly. Otherwise is quite easy and
>>> comfortable to send just compiled Lua table along with checksum over the UDP.
>>> In the short something like <size><bytecode><crc> in the packet. Imagine, that
>>> the Lua tables can contain functions, so the possibilities of such protocol
>>> are endless.

>> It is unsafe to receive and load raw bytecode.

> I shouldn't think aloud, it usually comes back to bite me. But I
> wonder how hard it would be to make a library by stripping down Lua so
> that it only implements enough to compile and load table constructors.
> Then you get a nice way to save/load arbitrary structures, an API to
> iterate and manipulate them, and compatibility with normal Lua. No?

It still would be slow. Specialized serialization library is faster.

AFAIR luabins.load() is about 7 times faster than loadsting. Saving is
about this much faster as well than my serialize-to-lua function.

> I'm fairly sure it would be possible to write a bytecode verifier for
> this small subset, also, to make loading into normal Lua safe within
> scripts. Perhaps even an in-Lua interpreter for it for the paranoid :)

Maybe, but why bother? Also, again, I think, it would be hard to make
it faster than specialized code.

Alexander.