Answer the question
In order to leave comments, you need to log in
Why are variables so rarely reused in programs?
The question in the header _________________________________________________________
Answer the question
In order to leave comments, you need to log in
Probably the question is why not use the already allocated memory for a variable of the type we need, rather than re-allocate it for a new variable to reduce the program execution time?
In high-level languages, variables are designed to fulfill each of their roles. otherwise, constructions of the form
int i=0;
for(;i<4;i++)
dosmth(i);
for(;i<7;i++)
dosmth(i);
What do you think is rare?
If you used the variable once and that's it, then perhaps the variable is needed only once or you have bad code in front of you.
After compilation in Assembler, they are reused with might and main, because even in virtual machines (C #, Java) the number of registers is limited. :)
But when writing code, they don’t do this, otherwise there will be confusion, it’s inconvenient to delete and add sections.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question