lua-users home
lua-l archive

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

It was thus said that the Great Andrew Starks once stated:
> On Tue, Oct 6, 2015 at 20:46 Sean Conner <> wrote:
> >   I recommend CBOR.  It's documented (RFC-7049), architectural independent
> > and extensible (for instance, there are documented extentions for circular
> > references), easy to encode/decode, and relatively compact.
> >
> I looked over CBOR. I don't have the chops to criticize it and it looks
> great to me. :) In my experience:

  [ ... ]

> Most importantly, something needs to be picked. A properly extended CBOR
> could be canonized on some kind of Lua web site. A library or 10 could be
> made that supported this format. Various concurrency / Lua-verses could
> adopt the format. Little Lua nodes could be working together with greater
> ease, thanks to this and Luaproc and cqueues and Luvit and Love2D and
> LuaLanes and....

  On a lark, I encoded the following using CBOR:

	x = { 1 , 2 , 3 }
	y = { }

	y[x] = y
	y[y] = x -- y is being encoded

	blob = cbor.encode(y)
	-- write blob out to file

  The binary sludge that popped out is:

	D8 1C A2 D8 1C A3 01 01
	02 02 03 03 D8 1D 00 D8
	1D 00 D8 1D 01

  Decoding that gives:

	-- read blob from file	
	t,v,p = cbor.decode(blob)
	for name,value in pairs(v) do

  And the output:

	table: 0x82e61c0
	table: 0x82d5d60	table: 0x82e61c0
	table: 0x82e61c0	table: 0x82d5d60

  I think I really need to get this code out there.