lua-l archive
[
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
] [
Date Index
] [
Thread Index
]
Subject
:
Small improvement of Automagic Tables behavior
From
: Egor Skriptunoff <egor.skriptunoff@
...
>
Date
: Fri, 4 Nov 2016 17:53:04 +0300
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
-- Egor
Follow-Ups
:
Re: Small improvement of Automagic Tables behavior
,
Dirk Laurie
Prev by Date:
Re: [With Apologies] LPeg Lua-Variant Language
Next by Date:
Re: Mass Inertia Matrix from URDF file
Previous by thread:
Re: Mass Inertia Matrix from URDF file
Next by thread:
Re: Small improvement of Automagic Tables behavior
Index(es):
Date
Thread