lua-users home
lua-l archive

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


> The main issue is whether global declarations as proposed solve the
> perceived need for global declarations.
> --lhf

Well, not having played with it yet (obviously :) I'm not sure if it solves
my problem or not.

The main issue for me, is that I'm using Lua to script an application
where (advanced) end users will be directly writing and modifying Lua
code.  The current problem is that most non-programmers won't really
be aware of the implications, they more or less think along the lines of
"cool I don't have to declare variables in this language"... this leads to
them inadvertantly having all function variables global, and so they
can easily get into variable name conflicts (most people use the same
small set of nams for 'general' variables, like "temp" or "i", "j", "k" etc)
and horrible side-effect possibilities.

Obviously anyone familiar with Lua, or any competant programmer
understands this and can work around it.  What I am looking for
is a way to cut down our tech support to end users for scripting
within our application.  This global variable issue is currently the
biggest potential cause of user confusion.

Does the new system fix this?  I'm not sure; if it means all users
are required to put "global in {}" at the start of every function
then I guess it doesn't really.  Also the fact dofile() doesn't
inherit the 'global scope' of the caller means that function libraries
could have problems too.

I suppose for me the ideal would be an explicit global declaration
and local-by-default behaviour.

Love, Light and Peace,
- Peter Loveday