Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.society.futures Subject: Re: C's sins of commission (was: (pssst...fortran?)) Message-ID: <63647@lanl.gov> Date: 21 Sep 90 00:17:43 GMT References: <9009202236.AA21344@raven.pa.dec.com> Organization: Los Alamos Natl Lab, Los Alamos, N.M. Lines: 42 From article <9009202236.AA21344@raven.pa.dec.com>, by mwm@DECWRL.DEC.COM (Mike Meyer, My Watch Has Windows): > [...] |> I goofed. Should have stated the problem, rather than trying to |> demonstrate it. |> |> The problem is with order of evaluation. You generally have to choose |> between three options: |> |> 1) Don't allow side effects, so that normally it isn't critical. |> |> 2) Specify it exactly, so you can predict side effects. |> |> 3) Leave it "undefined". |> |> This problem arises in all expressions, not just function arguments. |> There are problems with all three solutions. I was curious as to which |> was going to be taken in this case. Oh, well. If it's a question of side-effects. I oppose them outright. As a practical matter, you can convince most programmers that operators should not have side-effects. But, when it comes to functions, they always demand to be allowed side-effects. So, functions should be locally declared (in the interface or prototype or whatever you choose to call it) if they have side-effects. Those functions that don't, can be evaluated in any order in the expression. Functions that _do_ have side-effects should be evaluated in a specific order that can be determined by the user from looking at the source. Unfortunately, nested function calls and even funny operator precidence rules can require certain constraints on the evaluation order. The compiler has no trouble discovering these, but the user might. This can be hard for the user if several of the operators are "left- associative" while several others are "right-associative". Clearly, operator precidence should be consistent. And there should be as few different precidence levels as possible. In any case, the order of side-effects _should_not_ be left undefined. J. Giles