Hi!
There is a well-known implementation of automagic tables at
http://lua-users.org/wiki/AutomagicTablesUnfortunately, that implementation behaves weirdly in some situations:
local a = AutomagicTable()
local x = a.b.c
local y = a.b.c
assert(x == y) -- assertion fails !
local a = AutomagicTable()
a.pointer = a.array.elem2
a.array.elem1.n = "one"
a.array.elem2.n = "two"
a.array.elem3.n = "three"
assert(a.pointer.n == "two") -- assertion fails !
This behavior can be improved by storing weak references to all created objects.
https://gist.github.com/Egor-Skriptunoff/4ae0f2dbda089f368f3df52ef00c7554-- Egor