[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: The hypothetical __serialize metamethod (was Re: [ANN] luaproc 1.0-4)
- From: Sean Conner <sean@...>
- Date: Wed, 7 Oct 2015 13:27:28 -0400
It was thus said that the Great Andrew Starks once stated:
> On Tue, Oct 6, 2015 at 20:46 Sean Conner <sean@conman.org> 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)
print(v)
for name,value in pairs(v) do
print(name,value)
end
And the output:
table: 0x82e61c0
table: 0x82d5d60 table: 0x82e61c0
table: 0x82e61c0 table: 0x82d5d60
I think I really need to get this code out there.
-spc
- References:
- The hypothetical __serialize metamethod (was Re: [ANN] luaproc 1.0-4), Sean Conner
- Re: The hypothetical __serialize metamethod (was Re: [ANN] luaproc 1.0-4), Coda Highland
- RE: The hypothetical __serialize metamethod (was Re: [ANN] luaproc 1.0-4), Thijs Schreijer
- Re: The hypothetical __serialize metamethod (was Re: [ANN] luaproc 1.0-4), Coda Highland
- RE: The hypothetical __serialize metamethod (was Re: [ANN] luaproc 1.0-4), Thijs Schreijer
- RE: The hypothetical __serialize metamethod (was Re: [ANN] luaproc 1.0-4), Rena
- RE: The hypothetical __serialize metamethod (was Re: [ANN] luaproc 1.0-4), Thijs Schreijer
- Re: The hypothetical __serialize metamethod (was Re: [ANN] luaproc 1.0-4), Andrew Starks
- Re: The hypothetical __serialize metamethod (was Re: [ANN] luaproc 1.0-4), Sean Conner
- Re: The hypothetical __serialize metamethod (was Re: [ANN] luaproc 1.0-4), Andrew Starks