Re: [Vala] Why the temporary variables in the C code are usefull ?
- From: Jim Peters <jim uazu net>
- To: Jacques-Pascal Deplaix <jp deplaix gmail com>
- Cc: vala-list <vala-list gnome org>
- Subject: Re: [Vala] Why the temporary variables in the C code are usefull ?
- Date: Thu, 7 Jul 2011 15:54:55 -0500
Jacques-Pascal Deplaix 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.
Thanks. I give a clearer example of what you're saying:
y = x++ + --x;
No, that isn't what I meant. Someone who knows the Vala compiler well
could probably come up with a better example, but the compiler could
in theory transform this:
y = x++;
z = y * y;
into this:
z = x++ * x++;
But that would be a mistake. You need to hold that intermediate 'y'
value somewhere to avoid doing x++ twice. So some temporary variables
are always needed.
Jim
--
Jim Peters (_)/=\~/_(_) jim uazu net
(_) /=\ ~/_ (_)
UazĂș (_) /=\ ~/_ (_) http://
in Peru (_) ____ /=\ ____ ~/_ ____ (_) uazu.net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]