lua-users home
lua-l archive

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


Pierre Chapuis <catwell <at> archlinux.us> writes:

> ...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}},
> }
> 

I am confused, you can indeed add "markers" (via weak tables if you prefer a not
invasive approach) allowing a syntax like:

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

Would this be fine?

KR