Re: [Vala] Why the temporary variables in the C code are usefull ?



On 07/07/2011 07:09 PM, Jim Peters wrote:
Unwanted side effects can happen if you evaluate an expression more
than once, e.g. if you substituted the full expression for every
_tmp2_ in the C code.  Expressions with side-effects include function
calls and stuff which modifies variables, e.g. p++.  You don't want to
do 'p++' twice or call the function twice.

As the other poster said, C compilers are very good at optimising away
temporary variables.

Jim
Thanks.
I give a clearer example of what you're saying:

y = x++ + --x;

The result depends of compiler.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]