Path: utzoo!attcan!utgpu!watmath!att!chinet!kdb From: kdb@chinet.chi.il.us (Karl Botts) Newsgroups: comp.lang.c Subject: Re: comma operator Message-ID: <9226@chinet.chi.il.us> Date: 10 Aug 89 04:53:54 GMT References: <3287@ohstpy.mps.ohio-state.edu> <990@cbnewsd.ATT.COM> Reply-To: kdb@chinet.chi.il.us (Karl Botts) Organization: Chinet - Public Access Unix Lines: 34 >> Maybe I'm mistaken, but I'm sure that all the documentation I've read warns >> that the *comma* operator ----does not----- guarantee evaluation in any order. >> Specifically, the Microsoft 5.0 manual mentions this. >> >If this is true for MSC 5.0, they fixed it in MSC 5.1. It was never true, certainly not for any Microsoft compiler since 4.0, and not for any compiler I ever heard of (there have bben some that did not support the comma operator at all). I think there are legitimate places for the comma operator outside macro expnsions and loop control statements. YOu just have to remember that it has the lowest precedence of any operator, and thus must be protected with perens. Using the comma operator can emphasize that several statements are logically atomic -- that together, they are doing something which may be though of as asingle operation. for instance: i += x, j -=x; if ( i >= j ) ... I grant that the semi-colon can always be used in these cases, but I see no harm in the comma operator. I have also written code something like this: linked_list_node_t *p; if ( p && ( p = p->next, p ) ) /* something */ No doubt there are other ways to do it, but I don't see this as a sin.