Re: [CODE/IDEA] Invasion/ElectricFence

From: Chris Jacobson (fear@ATHENET.NET)
Date: 03/06/98


On 3/7/98 5:08 AM, X Schiltz (joes@SKIPNET.COM) stated:

>Am I missing something? Isn't the keyword "static" named so for a reason?
>To indicate that the variable cannot be changed?
>BTW, deincremintation might be better, you wouldn't have to keep a log for
>every event as to how many ticks it needs to...click...that's why Jeremy
>used deincremintation timers.

No, that is "const'.

Static means there is only 1 copy, and it is not destroyed between calls.

For example:

int myIncrementer(void) {
  static myInt = 0;
  myInt++;
  return myInt;
}

The first time myIncrementer is called, it returns 1.  The second time,
2.  The third, 3.  This is because only one copy of myInt ever exists for
this function, and it is only initialized once (that would be when the
program loads), unlike normal functions, where it creates the variables
every time it is called.  It functions sort of like a global variable,
that is really local to the function.

- Chris Jacobson


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST