Unpopularity of global variables - why?

William Vlahos bvlahos at mac.com
Mon Oct 15 21:00:16 EDT 2012

There can be other benefits of using globals if you want to make information available to other stacks on purpose.

In my lcTaskList plugin there is a global variable "gLcTaskListBookmarks" which contains the active words the plugin uses for building the indexed list. Mark Wieder was able to use that information in GLX2 to make it easy to put a bookmark word from a list of them into a script using the GLX2 editor.

The global variable name I chose should be unique enough to the task list plugin so that it would be very unlikely to be used by any other program.

By using a global variable, Mark was able to leverage user provided information contained in lcTaskList and apply it to software you are writing.

Bill Vlahos
InfoWallet (http://www.infowallet.com) is about keeping your important life information with you, accessible, and secure.
lcTaskList: (http://www.infowallet.com/lctasklist/index.htm)
RunRev lcTaskList Forum: (http://forums.runrev.com/viewforum.php?f=61)

On Oct 12, 2012, at 2:01 PM, Mark Wieder <mwieder at ahsoftware.net> wrote:

> Generally speaking (there are exceptions) the main reason global
> variables are a bad idea is that they have no protection. Any script
> in any stack can change the value of a global variable behind your
> back, and then it's a real pain trying to figure out what's going on.

More information about the Use-livecode mailing list