Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!umich!sharkey!amara!mcdaniel From: mcdaniel@adi.com (Tim McDaniel) Newsgroups: comp.lang.c Subject: Re: Evaluation of if's Message-ID: Date: 7 Jun 91 13:31:18 GMT References: <1991Jun4.233928.5185@athena.mit.edu> <1991Jun5.014758.10616@wdl1.wdl.loral.com> <20273@crdgw1.crd.ge.com> <1991Jun7.011938.11342@wdl1.wdl.loral.com> Sender: news@adi.COM Distribution: usa Organization: Applied Dynamics International, Inc.; Ann Arbor, Michigan, USA Lines: 44 In-reply-to: bard@cutter.ssd.loral.com's message of 7 Jun 91 01:19:38 GMT In article <1991Jun7.011938.11342@wdl1.wdl.loral.com> bard@cutter.ssd.loral.com (J H Woodyatt) writes: I might submit to you that all bets are off concerning the value stored in `i' after the expression is evaluated, but as for the result of the expression, if *that* is undefined, then it isn't by any means intuitive. (*) Not intuitive *to Mr. Woodyatt*. *I* find the ANSI C rule quite intuitive. (*) Who says that anything in C has to be "intuitive"? I suggest that one better guideline is "simple to remember", which is related to but not the same as "intuitive". Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be accessed only to determine the value to be stored. [ANS C, section 3.3] is simple to remember. (*) For the code in question, the code sequence (for a hypothetical memory-to-memory machine) MOV.I &i,#1 MOV.I &i,#2 CMP &i,&i is intuitive to me, and certainly legal by the standard. The intent of the standard is that compiler don't have to worry about multiple assignments between sequence points -- a considerable freedom. What about (*p = 1) == (*q = 2) ? It could take a lot of compiler work, in the general case, to get what Mr. Woodyatt call the "intuitive" result. Code that uses pointers could be utterly crippled (rather than partially crippled on parallel machines, as is the case in C now). -- "Of course he has a knife; he always has a knife. We all have knives. It's 1183 and we're barbarians." Tim McDaniel Applied Dynamics Int'l.; Ann Arbor, Michigan, USA Internet: mcdaniel@adi.com UUCP: {uunet,sharkey}!amara!mcdaniel