lua-users home
lua-l archive

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


On 2012-02-14 15:31, Ross Bencina wrote:
On 14/02/2012 9:15 PM, Josh Simmons wrote:
Not quite sure what you were saying before about standard container
classes? This is Lua after all, and we have the wondrous table which
manages quite well to subsume the common data structures.

I know the argument is getting old, just to clarify what I mean by
standard containers (maybe I mean "collections" if there's a
difference): I agree that table handles the mechanism, but it says
nothing about the intended use, nor does it's interface limit its use
to valid semantics of a specific container type.

To weigh in: the fact that there is no simple/efficient way to know
what a table represents is a problem when you try to serialize complex
structures to formats such as JSON or MessagePack. In your own code
you can choose a way to flag a table as a List/Array or a Map, but
it is impossible to design a library that implements a pack(example)
function that converts a structure such as `example` to JSON
efficiently:

example = {
  a = {1,2,3},
  b = {a = 1, b = 2, c = {1,2}},
}

--
Pierre 'catwell' Chapuis