defining and using globals in an application

Bob Sneidar bobs at twft.com
Fri Jul 8 12:50:22 EDT 2011


Yes, I saw namespace in the wiki. Are you saying that declaring a variable to be local or global is in fact referring to a namespace? In that case I am using the wrong term when I call it scope. 

Bob


On Jul 8, 2011, at 4:45 AM, Jim Ault wrote:

> 
> On Jul 7, 2011, at 9:11 AM, Bob Sneidar 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
>> 
> 
> 
> I think you should consider the word 'namespace'.  This means objects, processes, variables (reserved memory registers) are always created in some sort of namespace.
> 
> A real world example would be your refrigerator in your kitchen.  All of your neighbors have a refrigerator, but the contents of their freezer is independent of your freezer.  Their refrigerator is in a different namespace.
> 
> For an app running on Windows, Mac, Linux, etc.  there are always system variables that are accessible by those processes, and those processes make some of their variables available to others.
> 
> Your question ' How would the app know which you were talking about when you used it?'
> is that the app always knows the full path namespace of objects, variables, process threads, sockets, ... just as you would automatically know if you were opening your own refrigerator or your neighbor's.   Variables cannot float around in computer memory on their own.  Operating systems that allow that would crash constantly.
> 
> So, the fact that you get to refer to a variable by is 'short name' in a script does not mean there isn't a namespace definition in play.  If you observe carefully in the Variable Watcher window, you can see more that one entry in the list for a particular variable name, and this means multiple declarations are active, and you should correct your scripting to 'make this go away'
> 
> The result of the previous condition will let Livecode resolve the ambiguity of which variable to manipulate.
> 
> Hope this helps, and I welcome comments on how my discussion is inaccurate or misinformed.
> 
> 
> 
> Jim Ault
> Las Vegas
> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list