lua-users home
lua-l archive

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


Sean Conner <sean@conman.org> [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	[1]	RETURN   	0 1
	2	[1]	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.

-- ynezz