_G.fact = fact
In Lua 5.2 make that _ENV.fact = fact. It avoids the silly _G
convention *and* saves yet another table lookup. :-)
Yes, _G should not be used when _ENV==_G.
But no, _G is not a silly convention.
1. It is a good idea to keep a reference to the original environment
somewhere.
2. It is a good idea for everybody to use the same name for that
reference.
3. It is a good idea to allow assignments to that name, so that
Lua programs that wish provide a different default global
environment (e.g. to disable some libraries) can do so.
4. _G is as good a choice for that name as any other.
Of course, you must bear in mind that _G is just _ENV._G.