lua-users home
lua-l archive

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


2016-11-04 16:53 GMT+02:00 Egor Skriptunoff <egor.skriptunoff@gmail.com>:
> Hi!
>
> There is a well-known implementation of automagic tables at
> http://lua-users.org/wiki/AutomagicTables
>
> Unfortunately, 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

Please click on "edit" near the bottom left corner of the webpage and add
this comment and patch there, so that it becomes available to all future
readers of the Wiki entry.