Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
SilentDawn
Beginner


Joined: 19 Jan 2006
Posts: 11
Location: Sydney, Australia

PostPosted: 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.
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Wed Apr 12, 2006 1:59 am   
 
This has been touched upon elsewhere when Zugg outlined how variables are picked up in Class path specifiers - change in CMUD
_________________
Taz :)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net