The behaviour of i = i++ + ++i; is undefined? Really? Wow, what a huge piece of shit of a language they have there. This expression should expand to:
(+ (let ((k i))
(set! i (+ i 1)) k)
(begin (set! i (+ i 1))
i))
which will return 12. With Racket it's easy to understand why: you evaluate subexpressions from left to right. The first argument to + does return the original i (5), but it modifies i before the second argument is evaluated, which ends up returning the original i incremented twice.
So, what can we learn from this? Side effects are evil. Use functional programming.
>>6
Nowhere in the C standard does it say that the order of evaluation should be left-to-right. Rightly so: it allows programmers to follow the mathematical conventions for operator precedence in infix notation without having to use fucktons of parentheses.
>>6
Scheme doesn't specify the order of evaluation of sub expressions either. This gives freedom to the implementor of where to put intermediate values.
What a stupid thing to bash a language for. When would you ever do i = i++ + ++i; anyway?