On Mon, Aug 03, 2015 at 11:27:52AM -0400, Hendrik Boom wrote:
[cut]
>
> Interesting! You are right! I misread a comma as a semicolon.
>
> I never thought of using commas this way. Now I get to wonder whether
> this way of eliminating brackets is clarifying or misleading. It
> misled me.
The comma operator was not meant to clarify, but rather to compact
expressions, especially assignments and initialisations, and to some
extent also to ease the work to participants of the IOCCC [1]. Its
semantics is also quite similar to that of the comma operator found in
other languages, even funtional ones like Erlang. Guess it: the value
of a comma expression is equal to the value of the last expression in
the list, i.e.:
foo = (++x, y);
increments x and assigns y to foo. But beware:
foo = ++x, y;
does not assign y to foo, since "," is the C operator with the lowest
precedence :)
HND
KatolaZ
[1]
http://www.ioccc.org/
--
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net --
http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]