Expressions separated by the comma operator are always evaluated left to right. On the other hand function arguments (which are separated by comma) can be evaluated in any order.
That's correct (for C), but I feel the need to add that in function calls the parameters are separated by commas, and they can be evaluated in any order.
(e.g. http://isis.poly.edu/kulesh/stuff/src/klist/).
Requiring idiosyncratic setup of your list struct though.
Of course, I'm talking only about C, as I love to overuse lambda in Python like it's my job
index++, value=list->items[index]
with value=list->items[++index]
?You were not sure whether the increment would always happen before the assignment. In the combined expression you can simply use the pre-increment operator, which will always increment before the rest of the expression.
It's shorter, unambiguous and leaves less questions. How can something be any "cleaner" than that?
Also, the statements "array[index++]" and "array[++index]" are pretty well-understood idioms in C.
You'll notice that there's a footnote that isn't actually related to anything in the body of the comment. It's because the footnote was wrong; I just felt like it would be dishonest to hide it in the edit. (this is also the reason the edit: I did some looking around...) portion exists.
Interestingly, the edit happened prior to any child posts on the comment, and so was not really a reaction to being corrected. I'd actually googled and found [1], and realized (as someone else said) that function calls don't use the comma as an operator.
tl;dr; never, EVER expect left-to-right evaluation of arguments to a function :)
edit: I did some looking around and determined that the following is probably BS
[1] If you're wondering why I didn't do
it's because expressions separated by a comma can be evaluated in any order (I believe). My friend ran up against it with a bug in jscore.