Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!quanta.eng.ohio-state.edu!kaa.eng.ohio-state.edu!rob From: rob@kaa.eng.ohio-state.edu (Rob Carriere) Newsgroups: comp.lang.c Subject: Re: C optimizer Keywords: C pure function optimization Message-ID: <1398@quanta.eng.ohio-state.edu> Date: 15 Feb 89 17:26:58 GMT References: <515@larry.UUCP> <9648@smoke.BRL.MIL> <36034@bbn.COM> Sender: news@quanta.eng.ohio-state.edu Reply-To: rob@kaa.eng.ohio-state.edu (Rob Carriere) Organization: Ohio State Univ, College of Engineering Lines: 16 In article <36034@bbn.COM> mesard@BBN.COM (Wayne Mesard) writes: > A function which is entirely composed of known "pure" operations* > is, itself, pure. > >* Where pure operations is defined as functions that produce no side >effects and return deterministic values, and most operators (excluding >assignment to dereferenced pointers and globals). Hint: Sleep(3) would, >I believe, be labelled "pure" under this definition, so something's >still missing. What seems to be missing is the idea that sleep *does* modify something, namely time. So formally speaking, your compiler should consider sleep to have a side effect on a variable called __time. If you do that, there's no problem. SR