Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!usc!ucsd!nosc!logicon.arpa!trantor.harris-atd.com!x102c!bbadger From: bbadger@x102c.harris-atd.com (Badger BA 64810) Newsgroups: comp.lang.c Subject: Re: ambiguous ? Keywords: icon, order of evaluation Message-ID: <2816@trantor.harris-atd.com> Date: 26 Oct 89 20:21:32 GMT References: <1989Oct20.175352.20598@utzoo.uucp> <14102@lanl.gov> <1989Oct21.071319.8839@utzoo.uucp> Sender: news@trantor.harris-atd.com Reply-To: bbadger@x102c.harris-atd.com (Badger BA 64810) Organization: Harris GISD, Melbourne, FL Lines: 62 In article <1989Oct21.071319.8839@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: >In article <14102@lanl.gov> jlg@lanl.gov (Jim Giles) writes: [...] > >>... Presumably, if C >>made argument evaluation in function calls "well-defined", you would >>would have no qualms depending on their order either... > >Your presumption is incorrect. The whole purpose of && and || is to force >conditional evaluation, and hence evaluation order. I have no objection >to operators whose specific purpose is to force order, when they are >broadly useful. I do have considerable objection to code that depends >on evaluation order *without* putting the reader on notice of it by >explicitly using forcing operators. >-- >A bit of tolerance is worth a | Henry Spencer at U of Toronto Zoology >megabyte of flaming. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu I'm not sure if you're saying that a known order of evaluation (OOE) is a *bad* idea, or that you would rather accept an undefined order so that all possible compiler optimizations which may depend on the OOE would be legalized. There are languages which exploit either a free OOE or a fixed OOE to good effect. Edsker Djikstra's ``guarded command language'' from ``A Discipline of Programming'' has a non-deterministic form of iteration statement with a syntax something like: DO [] guard1 -> stmt1a; stmt1b; [] guard2 -> stmt2a; stmt2b; OD where ANY one of the statement lists with TRUE guards will be executed and then the guards re-evaluated. The DO-OD terminates when no guards remain true. Dr. Djkstra gives some examples where it is actually *easier* to prove the algorithm correct if a definite order of evaluation does not need to be taken into account. On the other hand, in Icon, order of evaluation of argument lists, is precisely defined as left-to-right. This fact, drives the sequencing of the ``mutual evaluation'' of all the arguments. Mutual evaluation may result in multiple evaluation of the arguments by backtracking through the results generated by each argument until all arguments can be satisfied simultaneously. The design of C mostly favors a simple compiler design which is free to evaluate arguments in any order which is convenient for the compiler writer, rather than serving any semantic purpose at all. It is fair to say that this no great asset to programmers who must now guard against an unnoticed argument order dependency. (IMHO) The classic C/UNIX philosophy, it's better to have something available that *can* work and just be careful not to shoot yourself in the foot. Of course, this occasionally fools the unwary and is a source of many ``gotchas''. ----- - - - - - - - ---- Bernard A. Badger Jr. 407/984-6385 |``Get a LIFE!'' -- J.H. Conway Harris GISD, Melbourne, FL 32902 |Buddy, can you paradigm? Internet: bbadger%x102c@trantor.harris-atd.com|'s/./&&/g' Tom sed expansively.