Clearing local variables

Richard Gaskin ambassador at fourthworld.com
Fri Apr 29 11:21:56 EDT 2016


Bob Sneidar wrote:

 > Agreed, but then you need to be careful about what any of your
 > variables contain. :-)

This sort of hints at a question I've been wondering throughout this 
thread:  why is this needed?

If you find yourself needing to clear variables of a particular scope, 
maybe that's reason to consider a narrower scope.

Wholesale deletion of all variables throughout a script seems likely to 
be a problem later on when a handler actually needs a persistent value 
in one of them  It's such an unusual thing to do that it's easy to 
imagine anyone working in that script a year from now being mystified 
when values they're depending on keep disappearing.

I don't understand the perceived need so it's not possible to have a 
useful opinion on this case in question, but as a general rule I tend to 
prefer to use the narrowest scope that'll get the job done, and if I 
need to clear it I'll write out a "put empty into ..." by hand rather 
than risk unanticipatable future issues by clearing all vars a script 
depends on.

If this is just needed during development the answer is even simpler: 
just turn off "Variable Preservation" in prefs.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com





More information about the Use-livecode mailing list