SilentDawn Beginner
Joined: 19 Jan 2006 Posts: 11 Location: Sydney, Australia
|
Posted: Wed Apr 12, 2006 1:34 am
Variable scope and temporary variables |
Rainchild touched on the idea of having temporary variables and I would like to consider the introduction of variable scope. I realise scoping might be a complex concept to introduce for the parser, but I believe it needs to go hand in hand with the use of packages.
At the moment it seems as though a variable, once declared or used anywhere, is permanently defined everywhere. This requires care to ensure that a variable name is not used in unrelated triggers incase one corrupts the value stored by the other.
With the introduction of packages, this becomes a much greater risk. At least if you are responsible for writing your code, you are aware of the variables in use. When you use someone else's package, you don't need knowledge of the code, possibly won't even be able to see the code.
My wishlist for scoping is as follows:
1. Variable defined in a trigger/alias = visible only in that trigger/alias
2. Variable defined in class folder = visible in that class and its triggers/aliases
3. Varialble defined in root = visible to all except packages (so its visible to all the code I have written, but not visible to packages I didn't write)
We will still need a way of declaring variables that will be seen by packages, perhaps with a #GLOBAL command?
If this is scoping structure is too complex to incorporate, could we at least have variable scopes for:
1. Visible by all code not in packages.
2. Visible only to code in single package.
3. Visible to all code and all packages.
Although as a coder I am familiar with encapsulation and like the use of variable scope, I am limited in my use of zMUD scripting. Feedback from you zMUD scripters please. |
|