Xref: utzoo comp.lang.c:12569 comp.lang.fortran:1094 Path: utzoo!attcan!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!mailrus!ames!haven!ncifcrf!nlm-mcs!adm!smoke!gwyn From: gwyn@smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c,comp.lang.fortran Subject: Re: C associativity rules Keywords: associativity, expressions Message-ID: <8483@smoke.ARPA> Date: 13 Sep 88 13:45:48 GMT References: <412@marob.MASA.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 18 In article <412@marob.MASA.COM> samperi@marob.MASA.COM (Dominick Samperi) writes: >Does K&R C or the new ANSI C permit the compiler to evaluate an expression >like a+b+c in any order it pleases, rather than in the strict left-to-right >order (a+b)+c ? I've always assumed that a strict left-to-right order would >be used, as is the case for relational expressions like the one in the >following. > while(i != -1 && a[i] != k) Why burden the net with this when it is easy to find in K&R? The theoretically associative and commutative operators have always been allowed to be rearranged in C. Before ANSI C (which hasn't happened yet!), this was true even if the programmer tried to enforce a particular grouping with parentheses (unlike Fortran). The operands of || and && operators obviously cannot be evaluated in reverse order due to the very definition of the || and && operators.