These are pretty trivial things:
In Objective C, you might observe something in a .m file that looks like
Which puts a variable (theSingletonInstance) in a specific location where code will be able to find it. But this declaration is outside any { scope }, so it is obviously not automatic. If you omit "static", what changes? I ask because I was once working on a program that had variables declared in a .h file, without the static specification, and they were, well, static.
Secondly, I am curious how people feel about using arguments as locals. As far as I can tell, they live on the stack, just above the return vector (or sometimes in registers, as with PPC) and C subroutines, as I read once long ago, do not clean up the stack upon return, so the caller might leave the argument frame in place if the subroutine is being called repeatedly in a loop (compiler optimization, perhaps). But really, how dangerous is it to alter the local value of arguments, once you no longer need the originals? Is it considered bad practice?
In Objective C, you might observe something in a .m file that looks like
Code:
#import ThisClass.h
static id theSingletonInstance = nil;
@implementation ThisClass
...
@end
Which puts a variable (theSingletonInstance) in a specific location where code will be able to find it. But this declaration is outside any { scope }, so it is obviously not automatic. If you omit "static", what changes? I ask because I was once working on a program that had variables declared in a .h file, without the static specification, and they were, well, static.
Secondly, I am curious how people feel about using arguments as locals. As far as I can tell, they live on the stack, just above the return vector (or sometimes in registers, as with PPC) and C subroutines, as I read once long ago, do not clean up the stack upon return, so the caller might leave the argument frame in place if the subroutine is being called repeatedly in a loop (compiler optimization, perhaps). But really, how dangerous is it to alter the local value of arguments, once you no longer need the originals? Is it considered bad practice?