lua-users home
lua-l archive

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


Chris Percival wrote:
> Is there a quick and easy way of making a lua script require variable
> declarations. I expect my program to have quite large lua scripts used
with
> it, and being able to just use a variable without declaring it first will
> allow all sorts of problems to arise. It reminds me of BASIC.. *shudder*.
> This is all IMHO of course. I saw somthing in the archives about using
> getglobal and setglobal functions, although idealy the fact that lua has
> been changed would be invisable from those writing lua scripts. I am using
> version 4.0 by the way.

Funny, some time ago, I though of asking something like the Visual Basic
"Option Explicit" declaration, which does exactly the same thing.

In other words, variable declaration is optional in VB, unless you put this
declaration in your program (there is an option to ask the IDE to do this
automatically for any new project). In this case, VB complains if you use a
variable without first declaring it.

I must admit that sometime I feel lazy and don't declare all my variables in
Lua. Such option would enforce a good programming style and avoid problems
like mispelling a long variable name, case errors, etc.

Regards.

-- 
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
http://jove.prohosting.com/~philho/
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--

Sent through GMX FreeMail - http://www.gmx.net