lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Goran Zoricic wrote:
> The solution we use is to wrap each script file inside 'function Main() ... end; Main();'. Then you can declare all functions as 'local' inside that scope. You can also use 'function self:Main() ... end;', and declare all functions inside as 'self:SomeFunction', adding those functions to the 'self' object, if you have one... This doesn't place the functions in the global environment, making function names reusable.

You don't actually need that dummy function --- a script is a chunk,
which has its own lexical scope, which means that you can use local
variables in it.

- --
+- David Given --McQ-+ "Preacher, don't the Bible have some pretty
|  dg@cowlark.com    | specific things to say about killing?" "Quite
| (dg@tao-group.com) | specific. It is, however, somewhat fuzzier on the
+- www.cowlark.com --+ subject of kneecaps." --- Firefly, _War Stories_
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEW2Iwf9E0noFvlzgRAvq8AJ4xoyy+Egewqn78qrYwGQh+z0HxcwCg1K/z
qiDWyS8An1CpcvyWkuEwZHg=
=YU5m
-----END PGP SIGNATURE-----