[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Integration of a new library in the Lua interpreter
- From: Reuben Thomas <rrt@...>
- Date: Wed, 10 Jul 2002 14:35:20 +0100 (BST)
> standard libraries), I have put the two tags in global variables.
> I know that global variables are often seen as evil these days: they pollute
> the namespace, so they may clash with other libraries, they can be changed
> by a function as a side effect, they can hurt the use of multithreading (each
> thread may need to have its separate, distinct value).
There are a couple of potential problems. First, when there may be
different Lua states assigning different values to the tag (because they
start up loading different libraries, or in a different order). Secondly,
if you want to build the Lua library as a DLL, it may not be possible
(e.g. on EPOC) to use globals at all, or unsafe (if globals are shared
It doesn't sound like it's a problem for you, but still since you already
have a safe implementation using upvalues to copy, it seems silly not to
use it. I did the same thing for my rexlib.
C++, n. an octopus made by nailing extra legs onto a dog (Anon)