Mail Archives: djgpp/2001/09/01/14:45:14
"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
- Raw text -