3 ms·
C's comma operator syntax is also weird and, in my experience, many people don't really understand it that well. edit: In reference to the last line: "oh this
by jotux 10y ago
C's comma operator syntax is also weird and, in my experience, many people don't really understand it that well.
edit: In reference to the last line: "oh this was a stupid idea, let's not take advantage of it".
It's a weird feature that generally makes the code more difficult to understand but people still use it a lot, similar to multiple declarations on a single line with pointers mixed in.
- penguinduck 10y agoMaybe you don't understand it that well because the described usage of a comma is not a comma operator (or any kind of operator).
- imtringued 10y agohttps://en.wikipedia.org/wiki/Comma_operator https://en.wikipedia.org/wiki/Comma_operator
- penguinduck 10y agoYour point? The multiple declaration syntax which is being discussed here uses comma separators, not operators.
- bluetomcat 10y agoThe comma acts as a separator in declarations, function calls and initializers. In ordinary expressions it is a normal binary operator (just like / or &&), but has the lowest precedence and simply evaluates the left-hand side, discarding the result, then (in that order) evaluates the right-hand side, returning its value as the result.