comma operator
Peter da Silva
peter at ficc.uu.net
Wed Aug 2 04:46:32 AEST 1989
Herewith the only use for the comma operator outside a macro that I can
think of:
for(init1, init2; test; incr1, incr2)...
For example:
for(i = 0, c = first(); i < MAX && c != TERM; i++, c = next())
whatever...;
This can be written, at the cost of some logical relatedness:
i = 0;
c = first();
while(i < MAX && c != TERM) {
whatever...;
i++;
c = next();
}
Which is IMHO less readable. In addition, if !whatever...;! contains any
!continue! statements, they would have to be implemented as gotos or the
!i++; c = next();! would have to be duplicated.
--
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Business: peter at ficc.uu.net, +1 713 274 5180. | "The sentence I am now
Personal: peter at sugar.hackercorp.com. `-_-' | writing is the sentence
Quote: Have you hugged your wolf today? 'U` | you are now reading"
More information about the Comp.lang.c
mailing list