[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Equality vs. Identity of userdata?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 04 Jun 1998 17:47:55 -0300
> What exactly is the behaviour of lua_pushusertag(u,t) ?
For userdata, equality is identity.
If there is a userdata u with tag t in the Lua environment,
this same object is reused when you push it again.
That is, there is only one copy of
equal objects in the environment. If you want to do reference-count,
all you need is a boolean. When you push an object (void *) into
Lua, set the boolean to true. When Lua calls the gc fallback, set
the boolean to false: It means Lua has no more any reference to this