[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Removing userdata variables!
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 27 Aug 1998 14:00:25 -0300
> The way I've always handled this is to create a tag number just for
> "dead" variables, and change the lua Object to the dead tag number
> using lua_settag(). That way, you can know its not valid anymore
> and not use it, even if it is still in scope under Lua.
We use this same approach for files, in the I/O library. When a file is
closed, we change its tag, so any future operation on it can detect the
> t = readfrom("lua.c")
> readfrom() -- close t
lua: cannot access a closed file
function read [in chunk (C)]
main of (dostring) >> "read(t)"