I'm aware of the weak tables functionality in Lua, however I would like to have a weak reference with a single variable.
I've seen this proposal which suggests an API as follows:
-- creation
ref = weakref(obj)
-- dereference
obj = ref()
which would seem ideal. However this doesn't appear to be in the documentation elsewhere; only weak tables.
Is there something analogous to Python's weak reference to object functionality?
newproxy
and a metatable) if you really need to. – Scrutineer__call
to get you theref()
syntax where either the table itself or the metatable were weak and held the reference. – Scrutineerref.real
orref.obj
or whatever instead ofref()
. – Scrutineer