From: "Matthew Smith" Newsgroups: comp.os.msdos.djgpp Subject: Re: variables Date: Sat, 1 Sep 2001 19:46:28 +0100 Lines: 41 Message-ID: <9mr9ul$dbn$1@news8.svr.pol.co.uk> References: <20010901131037 DOT 03480 DOT 00004579 AT mb-fp DOT aol DOT com> NNTP-Posting-Host: modem-320.beedrill.dialup.pol.co.uk X-Trace: news8.svr.pol.co.uk 999369493 13687 217.135.33.64 (1 Sep 2001 18:38:13 GMT) NNTP-Posting-Date: 1 Sep 2001 18:38:13 GMT X-Complaints-To: abuse AT theplanet DOT net X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Sterten" wrote ... > why are variables not initialized as 0 ? it's a tradition which stems from the physical reality of electronic computers. When you first apply power to a memory chip, the contents are a semi-random jumble. It may not always be necessary or desirable to zero variables so C does not > is there any reason, why "int x" can be better than "int x=0" ? Its a microscopic bit faster int x; declares that x is an int int x=0; declares that x is an int, and puts a 0 there. > why do we have to define variables at all ? In BASIC I can use > variables without declaring them. (default = float) BASIC manages all of this for you. It makes learning easier but large BASIC programs suffer from slow-downs when you have many variables. When you manage your own variables you can predict more reliably what will happen when you scale things up. You have to accept that C programs are much more verbose, and I agree it does seem a bit unnecessary sometimes, but you ultimately have more control. In a sophisticated BASIC like VB you can use Option Explicit which makes the rules very similar to C and C++ > > I've read, that the new processors will have more registers. > Then we might use register-variables much more often ? > If current GCC/DJGPP uses only -say- half of the registers available , > then can't they use e.g. all loop-variables as register by default ? > The way gcc is written, it will make good use of any new registers provided they can be used as regular 32 bit ones. Matt