defining and using globals in an application

Bob Sneidar bobs at twft.com
Thu Jul 7 14:19:59 EDT 2011


http://en.wikipedia.org/wiki/Scope_(computer_science)

Not to beat a dead horse, but I don't see the difference. I think it's a matter of semantics. According to this wiki, a scope can "contain statements and/or expressions which define an executable algorithm or part thereof;" It seems like it is saying both procedures and variables are contained in a scope. Still, I do not have a degree in computer science and am only a hobbyist. 

My point was, the same variable cannot have 2 scopes, or if you will, be contained in two scopes. You can have more than one variable that use the same NAME, but not visible to the same handler, because they are in fact two different variables in two different memory locations. 

But it is all academic anyway, as the practice of having two variables with the same name in the same app is a really bad idea. It only comes into play in the dev environment because you can have multiple "applications" running at the same time, and changes to a same named global defined in more than one of them will overwrite the value expected by another, and so wreak havoc. 

Bob

 
On Jul 7, 2011, at 9:49 AM, Nonsanity wrote:

> On Thu, Jul 7, 2011 at 12:11 PM, Bob Sneidar <bobs at twft.com> wrote:
> 
>> I don't think it's a bug IMHO. How can a variable in the same script have 2
>> scopes? How would the app know which you were talking about when you used
>> it?
>> 
>> Bob
> 
> 
> 
> Ah. Variables don't a have scope, they live inside scopes.
> 
> A handler has a scope. If you "put 5 into x" in a handler, that x won't be
> accessible from anywhere else. It was defined inside the scope of the
> handler.





More information about the use-livecode mailing list