lua-users home
lua-l archive

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


On Thu, 31 Jan 2002, J. Perkins wrote:

> But really two tables are required, right? One for locked refs
> and another for unlocked? And then the reference value must also
> indicate which table it is stored in, [...]

Usually you know whether a reference points to a locked or unlocked object,
so it does not need to include that information.

(If you really want to emulate the old behavior, you can use two tables,
one weak and one strong. You put all elements in the weak table,
but only locked ones go to the other table. That way, your references
are always to the weak table; you do not need negative indices. To unref,
you set the ref to nil in both tables. But, as I said, I think most
people don't need that.)



> Is there some reason why unlocked refs were dropped?

It was replaced by weak references (and, unlike some other languages, we
do not need more than one way to do something ;-). But also the whole
system of references was somewhat outdated by multiple states. And there
is a tendency in Lua to unificate all data structures into tables.
Globals went to tables, now tag methods and references are going, too.

-- Roberto