Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Question about static vs global variables

Author: Robert Hyatt

Date: 13:33:54 10/27/01

Go up one level in this thread


On October 27, 2001 at 05:53:59, Frank Phillips wrote:

>Are there any issues associated with time?  Presumably at runtime storage has to
>be created for local variables in a recursive function, such as ABSearch(), and
>then destroyed; whereas it has to be created only at initialisation for globals.
> Having said that, I used to have local arrays for the move list and never
>noticed much if any speed difference (and still use them for testing).
>
>Frank


This is not an issue.  When you enter a function, you simply
increment the stack pointer by an amount equal to the number of local
variables in the procedure.  Then all local memory references are simply
constant offsets from this new stack pointer address.

No overhead of any kind to allocate, and upon exiting, the stack pointer
gets backed up anyway so the memory is effectively forgotten about with no
action needed.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.