Path: utzoo!mnetor!uunet!husc6!bbn!rochester!cornell!uw-beaver!uw-june!pardo From: pardo@june.cs.washington.edu (David Keppel) Newsgroups: comp.lang.c Subject: sequence points (WAS: Re: comma operator) Message-ID: <4055@june.cs.washington.edu> Date: 22 Jan 88 23:25:09 GMT Organization: U of Washington, Computer Science, Seattle Lines: 38 Keywords: sequence points code motion ---- John Nelson sent me part of the ANSI draft standard having to do with program execution. Basically, under the new standard things such as foo = bar, baz = bum; can be rearranged arbitrarily by the compiler as long as they obey sequence-point rules. The draft also mentions that the logical-AND and logical-Or operators impose sequencing points. This leads me to the following proposal: if ( bool1 && bool2 ) { ... } means exactly what it has always meant. if ( bool1 &&& bool2 ) { ... } means that the compiler can evaluate either or both arguments and in any order, whatever is the fastest. For more complex expressions, the compiler is allowed to use DeMorgan's theorem and any other apriori information it has at hand to speed the computation of the boolean. If part of the expression is written using the short-circuit form of the operators, then that part of the expression _must_ be evaluated in short-circuit form, but the rest of the expression can be reordered: if ( cp && ((*cp != 'a')|||(*cp != 'c')|||(!*cp)) ) { ... } The "obvious" candidates are "&&&" and "|||". I wonder if (a) there are any others (b) if this is at all a good idea Please respond by e-mail, I'll summarize. ;-D on (Well it _seemed_ like a good idea!) Pardo