On 29 Jan 2010, at 16:12, Aleksa Todorovic wrote:
Depends. I do see a minor point for e.g. ++ and --, since I have
been bitten
by that when translating e.g. compression code (paszlib, lz77) when
these
are used in complex nested loops.
Hopefully, it would be easy to implement it "manually":
function PreInc(var value: T; Delta: Integer = 1): T;
function PostInc(var value: T; Delta: Integer = 1): T;
The post-increment is only evaluated after the entire expression has
been evaluated in C (and even that simplistic description is probably
wrong if you put it next to what the standard actually says). E.g.:
int i, j;
i = 0;
j = i++ + i++;
After this, i=2 and j=0 (rather than 1).
Anyway, pre/post-increment operators are not a good idea. They are
also discouraged by many C programmers these days (except in for-
statements or single line statements equivalent to inc(i) in Pascal),
because it can sometimes be very hard to understand the side effects
in complex expressions (different C compilers can give different
results with some expressions, because the C standard gives compilers
quite some freedom regarding the evaluation order).
Jonas
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel