On Apr 11, 6:06 pm, Eric Sosman <esos...@ieee-dot-org.invalidwrot e:
prog output.txt
But I guess when you look at the data eventually, the global variable
will rear its ugly head.
After chasing down problems due to globals (it used to be worse, with
Fortran common blocks which were often treated like public unions)
it's easy to get sick of 'em.
They are not all evil. Only most of them.
The ones I hate are the totally unnecessary ones, spawned from lazy
thinking.
Bartc wrote:
>
>
>
I have no patience with zealots who argue that all global
variables are ipso facto evil. When someone does so, I delight
in offering
>
#include <stdio.h>
int main(void) {
puts("Hello, world!");
return 0;
}
>
... and inviting him to eliminate the global variable, that is,
the global variable whose name isn't even mentioned!
[...]
But take this one example of a global variable (the code was not C):
But take this one example of a global variable (the code was not C):
byte winnt /* set to 1 when this is WinNT, 0 otherwise */
What was I supposed to do with that? A few functions out of thousands need
to know that value.
to know that value.
I have no patience with zealots who argue that all global
variables are ipso facto evil. When someone does so, I delight
in offering
>
#include <stdio.h>
int main(void) {
puts("Hello, world!");
return 0;
}
>
... and inviting him to eliminate the global variable, that is,
the global variable whose name isn't even mentioned!
But I guess when you look at the data eventually, the global variable
will rear its ugly head.
And yet, I feel there is reason to avoid global variables.
They grow like kudzu, they induce unexpected and unwanted
couplings between modules that could have been independent, they
make debugging harder ("I can see that foo() crashes because the
value of global variable bar is invalid, but how in God's green
earth did bar get clobbered?") And there's always the chance --
as in my lengthy tale of woe upthread -- that your code will be
recycled into a situation where the Singleton is non-singular
and encounters a singularity ...
>
I use 'em, but only when there are no witnesses.
They grow like kudzu, they induce unexpected and unwanted
couplings between modules that could have been independent, they
make debugging harder ("I can see that foo() crashes because the
value of global variable bar is invalid, but how in God's green
earth did bar get clobbered?") And there's always the chance --
as in my lengthy tale of woe upthread -- that your code will be
recycled into a situation where the Singleton is non-singular
and encounters a singularity ...
>
I use 'em, but only when there are no witnesses.
Fortran common blocks which were often treated like public unions)
it's easy to get sick of 'em.
They are not all evil. Only most of them.
The ones I hate are the totally unnecessary ones, spawned from lazy
thinking.
Comment