Avoiding Global Variables - revUp 93

Richard Gaskin ambassador at fourthworld.com
Sun Jun 6 12:52:50 EDT 2010


Robert Earp wrote:

> I'm concerned that readers of the article, especially new people to
> Rev and scripting, will now stay away from global variables, which
> would be a shame as they are extremely valuable.   I believe the crux
> of the Olivers concerns about global variables is one of scripting
> practices and project documentation, rather than global variables
> themselves.
>
> There's absolutely nothing wrong with global variables, in fact I much
> prefer them to other means of storing data especially when wishing to
> access that data across multiple stacks and/or locations.  Global
> variables are truly global, and as such save an awful lot of
> addressing problems which ends up in simpler script.  But I do agree
> in using custom properties of objects, or groups, when the data truly
> refers to something associated with the object/group.

Thank you for that, Bob.

There is indeed a stigma against global variables, and while a good many 
programmers continue to argue against their use nearly every language 
they use supports them.  I doubt the designers of programming languages 
are all so wrong.

Like you noted, there's a place for globals, and it's also true that 
globals can be abused, just as custom props and other containers can be 
abused.

Rather than lead newcomers down the dogma road of avoiding globals 
altogether, it would be more helpful to assist them in distinguishing 
when they are useful.

--
  Richard Gaskin
  Fourth World
  Rev training and consulting: http://www.fourthworld.com
  Webzine for Rev developers: http://www.revjournal.com
  revJournal blog: http://revjournal.com/blog.irv



More information about the use-livecode mailing list