Wondering if this would be a dangerous use of globals.
Er, quick clarification, but are globals bad because they're sloppy, or do they also cause overhead?
Anyway, that script interpretor I've been working on. I'd like to have four global variables -- three vectors, and a stack. Keep in mind that these aren't necessarily TRULY global. They might be in a function of some sort. However, they'd be pretty much open, so no matter what I stick them in, they'd probably act open. That, and I'm probably going to be declaring them extern, which... causes some sort of globalization anyway?
The vectors are as follows: One for script-created variable names, one for the data for these vars, and a current_thing vector, which just floats around, absorbing data from other vectors for SPECIAL PROCESSING. The stack's just some stack that anything can be stuffed into. Ideally, it'll be empty unless it's in use.
I don't think the access will be a problem here. Only one or two functions will be able to alter the current_thing vector in ANY way. The other two will be, primarily, having things added TO them. And while it's technically possible to remove stuff from them via scripts, there's no real reason to do this. And even then, the problems that would be caused would be more from improper scripting than the globalness.
The stack kinda worries me here. I'm afraid something will accidentally get left on it, and this gunk will build up, like creme of tartar on the basin of a wine barrel, and slowly devour the system's chocolatey innards (ed note: I do not have a chocolate computer). Then again, the stack just takes strings, so unless thy're particularly massive strings, or particularly numerous, I think THIS should be okay.
I'm not sure about the infinite possibility for mutual dependency thing. This is very blatantly a BAD HAPPENING if it occurs. I BELIEVE that the read/write functions should be limited and controlled enough that nothing will break. Current_thing makes me suspicious, though, because I'm not particular sure how that'll get coded and how I'll be picking it apart.
I guess I'm just wondering, if I do go ahead and go global (or use locals in a global-esque manner) what are some potentially VERY BAD THINGS to look out for? Any tips on managing these things in ways that aren't global, or ways at improving management?
(* I could probably safely pass references to these things to the functions, although I doubt that'd alleviate the Totally Random Access problems. If anything, I'd fear that this would be MORE sloppy. In this instance, I genuinely believe that, at the least, the stacks and data vectors should stay in one place. Current_room could probably get safely passed around, though).