Re: [dev] Re: Local vs global variables

From: Aled Gest <>
Date: Fri, 6 Nov 2009 20:51:32 +0000

> No he is my boss at my work, we were discussing, and I said that
> sometimes I use global variables and everybody laughed at me.

Unless they can explain specifically why it's a bad idea, I suggest
you laugh right back at them.

> It is rare but sometimes I use a goto.

People who unconditionally say "goto is bad" are idiots who don't
understand how computer programs work.

>> Is he sure he never uses global variables?
> That I don't know, he did not tell me, but I am sure he uses them.

Unless he makes absolutely no use of malloc and friends and doesn't
use any string constants, he uses 'global variables'. There's nothing
special about global variables, they're just data that gets allocated
on the heap and isn't bound to any particular function call. The only
time use of global variables can be 'dangerous' is when your program
is multi-threaded, in which case, if you're passing pointers around
the place you're not necessarily safer using 'local' variables.

Good programmers will always pay attention to what their code does and
how it's used by the compiler, and that's the only rule you really
need to follow. Any feature used improperly is bad, any feature used
properly is a tool at your disposal.
Received on Fri Nov 06 2009 - 20:51:32 UTC

This archive was generated by hypermail 2.2.0 : Fri Nov 06 2009 - 21:12:01 UTC