TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Frank Adam
from: Paul Edwards
date: 1996-10-15 05:33:08
subject: Auto string-length deter

PW> I was taught to "hate" global variables...  Come to think
of it -- why
PW> ARE they bad anyway?

FA> I think it's just that, having the variables declared near the procedure
FA> using them, makes the code more readable. On larger programs a number of 
FA> functions may act on the same global variable making it hard to keep track 
FA> of things after a while, strange bugs etc...

On larger programs a number of functions may call the same global function
making it hard to keep track of things after a while, strange bugs etc...
e.g. strtok().  If it's OK to call a function that will store a variable
into a database, it's OK to stick the data in a global variable too. 
They're mathematically equivalent.

In the case of strtok(), you could say that it should be written so that it
operates purely on parameters, ie the function shouldn't have static
variables, which means only one person can use them.

In the end, I don't use global variables anymore, e.g. Tobruk.

BFN.  Paul.
@EOT:

---
* Origin: X (3:711/934.9)
SEEN-BY: 633/267 270
@PATH: 711/934 808 50/99 635/544 727 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.