From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,dab7d920e4340f12 X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,dab7d920e4340f12 X-Google-Attributes: gid103376,public From: ian@rsd.bel.alcatel.be (Ian Ward) Subject: Re: C is 'better' than Ada because... Date: 1996/08/01 Message-ID: <4tqi6k$mbb@btmpjg.god.bel.alcatel.be>#1/1 X-Deja-AN: 171451144 distribution: world references: <3200A849.372A@lmtas.lmco.com> organization: Alcatel Bell Telephone reply-to: ian@rsd.bel.alcatel.be newsgroups: comp.lang.ada,comp.lang.c Date: 1996-08-01T00:00:00+00:00 List-Id: In article 372A@lmtas.lmco.com, "Byron B. Kauffman" () writes: >Tim Behrendsen wrote: >> >snip... >> >> You are probably right, if you let the optimizer handle everything. >> But C also gives the capability to do things such as ... >> >> if ((array[++n] = GetValue(arg)) != 0) { >> .... >> >> v.s. a typical non-C language ... >> >> n = n + 1; >> array[n] = GetValue(arg); >> if (array[n] != 0) { >> ... >> } >> >> Now, which is easier to optimize? (more snip) >> Can I just ask, whether these would result in different code to be generated? I would have thought that any decent compiler would generate the same code for both. (I have not written a _modern_ compiler though, so I cannot be sure.) The only difference between these two cases is that the second uses more characters and is a bit easier on the eye. (Actually both are quite easy on the eye, but these are very simple cases. I can imagine a more complex case, say involving half a dozen different pointers to functions returning an array of pointers to arrays of pointers to an array of functions returning a pointer to int, where the first example would be much more concise than the second example. I still think in the complex case that the resultant assembler would not be too much different.) Anybody au fait with current 'C' compilers to confirm this? --- Ian Ward's opinions only : ian@rsd.bel.alcatel.be