]> git.lizzy.rs Git - metalua.git/blob - doc/manual/declare-globals-ref.tex
f60e3b87afe02ba9ce9879c3ad95acede2691ac2
[metalua.git] / doc / manual / declare-globals-ref.tex
1 \section{Extension {\tt declare\_globals}: mandatory declaration of global\r
2   variables}\r
3 There is a {\tt strict} library in Lua, also provided by metalua, which\r
4 complains when one tries to access a global variable which hasn't been\r
5 initialized, and when a global variable is initialized anywhere but at the\r
6 program's top-level. This catches many errors, especially typos on variable\r
7 names. \r
8 \r
9 However, with a macro-enabled language, we can do slightly better: we add a {\tt\r
10   global} keyword, which works as {\tt local}, allows to declare global\r
11 variables, which can subsequently be used freely. Undeclared global variables\r
12 cause an error when one tries to read or write them.\r
13 \r
14 FIXME: need a ``global function ...'' syntax; interactions with sub-modules is\r
15 not tested correctly.\r