Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!uakari.primate.wisc.edu!indri!polyslo!csun!csuna!abcscnuk From: abcscnuk@csuna.csun.edu (Naoto Kimura) Newsgroups: comp.lang.pascal Subject: Re: Funny evaluation of functions Message-ID: <2161@csuna.csun.edu> Date: 26 Aug 89 00:08:24 GMT References: <20693@adm.BRL.MIL> <1989Aug24.122149.18977@aucs.uucp> Reply-To: abcscnuk@csuna.csun.edu (Naoto Kimura) Organization: CSU Northridge Lines: 27 As was stated a zillion times already: Avoid using expressions where the order of evaulation may make a difference. Using functions with VAR parameters can be hazardous in such cases, also those that change global variables (such behavior is known as "side effects" as many people have noted). Don't rely on the order of evaluation when it comes to parameters to a function or procedure call, as this would be dependent upon the implementation. This becomes especially important if you want to transport your code to a different computer or just a different compiler. This actually bit me hard when I tried to port a C program (I know, I know, this isn't the newsgroup to mention that language, but I haven't run across the same problem in pascal yet) when there was an auto-increment of an index variable in one of the parameters. Don't rely on the availability of short-circuit evaluation of booleans. Nor should you rely on the availability of complete evaluation. Try to make your boolean expressions independent of such things. And last, but least, there are some exceptions to these rules. //-n-\\ Naoto Kimura _____---=======---_____ (abcscnuk@csuna.csun.edu) ====____\ /.. ..\ /____==== // ---\__O__/--- \\ Enterprise... Surrender or we'll \_\ /_/ send back your *&^$% tribbles !!