Path: utzoo!attcan!utgpu!watmath!maytag!watstat!dmurdoch From: dmurdoch@watstat.waterloo.edu (Duncan Murdoch) Newsgroups: comp.lang.pascal Subject: Re: Funny evaluation of functions Message-ID: <407@maytag.waterloo.edu> Date: 24 Aug 89 12:55:16 GMT References: <20693@adm.BRL.MIL> <2974@mace.cc.purdue.edu> Sender: daemon@maytag.waterloo.edu Reply-To: dmurdoch@watstat.waterloo.edu (Duncan Murdoch) Organization: U. of Waterloo, Ontario Lines: 19 In article <2974@mace.cc.purdue.edu> ags@mace.cc.purdue.edu (Dave Seaman) writes: >In an expression like "x*one(x)", it would be possible to skip the >evaluation of the function "one" if x happens to be zero. If "one" has >side effects, then the result is implementation-dependent. Assuming that >both terms are evaluated, they may be taken in either order. Another example I just saw of a function with side effects causing problems was in porting dvitty from Unix Pascal to Turbo. At one point (in an out of date copy) is a line something like do_something(getvalue,getvalue); where getvalue is a function that reads a file to get a value. On Unix, the second getvalue was evaluated first, and the program worked; in Turbo, the functions were evaluated from left to right, and the procedure ended up with its parameters reversed. Similar things could happen in any expression that tried to read more than one value from a file. Duncan Murdoch