[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Protocol Specification in Lua
- From: Petr Štetiar <ynezz@...>
- Date: Sat, 2 Oct 2010 17:24:19 +0200
Sean Conner <email@example.com> [2010-10-02 06:07:10]:
> It was thus said that the Great Petr Štetiar once stated:
> > 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.
> Okay, now I'm curious---how does one *get* a compiled Lua table? I can
> see how to get a Lua function (in fact, I'm doing that now, only between
> separate Lua instances and not over a network connection) but a table?
Ok sorry, wrong wording. If we're talking about stock Lua there's always some
kind of "main" function:
$ echo return > a
$ luac -l a
main <a:0,0> (2 instructions, 8 bytes at 0x8903d00)
0+ params, 2 slots, 0 upvalues, 0 locals, 0 constants, 0 functions
1  RETURN 0 1
2  RETURN 0 1
What I'm trying to say is, that yes, you're correct, you'll always need to
wrap the code in some kind of function.