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 François Perrad once stated:
> Hello list,
> 
> The Concise Binary Object Representation (RFC 7049) is a data format
> whose design goals include the possibility of extremely small code size,
> fairly small message size, and extensibility without the need for
> version negotiation.
> 
> It's a pure Lua implementation, without dependency.
> 
> This implementation is based on my previous work on
> http://github.com/fperrad/lua-MessagePack
> 
> The homepage is at http://fperrad.github.io/lua-ConciseSerialization/.
> 
> Comments and feedback are welcome.

  I noticed in your Makefile you have:

	LUAVER := 5.1
	LIBDIR := $(DPREFIX)/share/lua/$(LUAVER)

That means you have to edit LUAVER manually.  I fixed that by doing:

	LUA         = lua
	LUA_VERSION = $(shell $(LUA) -e "print (_VERSION:match '^Lua (.*)')")
	LIBDIR      = $(LUA_DIR)/lib/lua/$(LUA_VERSION)
	LUADIR      = $(LUA_DIR)/share/lua/$(LUA_VERSION)

I have Lua itself tell me what version it is.

  I found the API itself interesting.  When I wrote my CBOR module [1] I
check the strings and if they pass as a UTF-8 string, I encode the string as
TEXT; otherwise it gets encoded as BIN.  It never occured to me to have a
function set the default behavior, and I wonder how your method would work
with a table of mixed strings and binary data (or is that even enough of a
concern to conern yourself with?  I don't know ... ).  

  You do a similar thing with arrays, but it's rather terse about the
'with_hole' option---how does that work?  Does the code in that case look
for a field 'n' in the table?  I just assume if a table has a length
defined, it's encoded as an ARRAY; otherwise a MAP (and because of that, an
empty table is encoded as a MAP).  

  Also, you might want to support __tocbor.  The other two Lua implentations
listed at http://cbor.io/impls.html support that.  And you might want to add
yours to that list.

  -spc (It's always cool to see how others solve problems ... )

[1]	https://github.com/spc476/CBOR