tags:

views:

242

answers:

2

Puzzled by the Lua 5.0 documentation references to things like _LOADED, LUA_PATH, _ALERT and so on (that I could not use in Lua 5.1), I discovered all of those have been removed and the functionality put elsewhere. Am I right in thinking that the only one global variable left in Lua 5.1 is _VERSION?

+2  A: 

The docs seem to think that's almost the case....

_G A global variable (not a function) that holds the global environment (that is, _G._G = _G). Lua itself does not use this variable; changing its value does not affect any environment, nor vice-versa. (Use setfenv to change environments.)

It looks like there's also _PROMPT and _PROMPT2, but only when using standalone lua interactively:

If the global variable _PROMPT contains a string, then its value is used as the prompt. Similarly, if the global variable _PROMPT2 contains a string, its value is used as the secondary prompt (issued during incomplete statements). Therefore, both prompts can be changed directly on the command line or in any Lua programs by assigning to _PROMPT.

Mike G.
That's from http://www.lua.org/manual/5.1/manual.html#pdf-_G for reference's sake. The same page also mentions the use of _PROMPT and _PROMPT2 in the standalone interpreter.
A. Rex
+1  A: 

Assuming you don't open ANY libs, there's also '_G', 'pairs', 'ipairs' and 'newproxy'.

pairs and ipairs are functions available globally, not variables. not sure about newproxy.
Kevlar
All functions are values, and often stored in variables such as the global variable pairs.
RBerteig