Author: Robert Hyatt
Date: 07:07:25 07/30/04
Go up one level in this thread
On July 29, 2004 at 20:52:37, Uri Blass wrote: >I thought to have some static local varaibles for things like remaining number >of moves to the time control or time_used and I looked at time.cpp of Crafty and >found that Crafty is using global varaibles. The issue with local vs global is simple. Global data is used by everything, local data is only used by a sub-set of the total code or by a single thread. Time info is global by definition, and all threads need access to it, therefore everything is global. But there is one important rule, namely that global variables don't get modified everywhere which makes understanding and debugging the code more complex. The code that modifies and uses the global time variables is located in time.c... DisplayTime() is not about setting and testing time limits, it is used to display the time in a more readable form, and it is used all over the place. Hence its location in utility.c > >I also found that some functions like DisplayTime are in utility.c and not in >time.c >I wonder if it is a good programming and if there is a special reason for it? >After all time varaibles are not varaibles that are used very often during the >search so it may be better to have less global varaibles and if I want to use >time varaibles to call a function that is in the time.c file in order to do it. Global vs local is not about how often they are used... > >Uri
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.