Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!unm-la!lanl!cmcl2!yale!wald-david From: wald-david@CS.YALE.EDU (david wald) Newsgroups: comp.lang.c Subject: Pure Functions (was Re: C optimizer) Message-ID: <50915@yale-celray.yale.UUCP> Date: 16 Feb 89 21:39:17 GMT References: <1398@quanta.eng.ohio-state.edu> <2008@goofy.megatest.UUCP> Sender: root@yale.UUCP Reply-To: wald-david@CS.YALE.EDU (david wald) Organization: Yale University Computer Science Dept, New Haven CT 06520-2158 Lines: 25 In article <2008@goofy.megatest.UUCP> djones@megatest.UUCP (Dave Jones) writes: >From article <1398@quanta.eng.ohio-state.edu>, by rob@kaa.eng.ohio-state.edu (Rob Carriere): >> 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. > >Huh?? > >On a time-shared system (such as Unix), does every instruction have >a side effect on a variable called __time? Point taken, but we still need a way to describe the difficulty with treating sleep() as a pure function. The actual difficulty is related to the problem with volatile variables. The compiler can't optimize sleep() calls away, since they rely on some external (volatile) clock variable (or some system call accessing this variable) for their behavior. ============================================================================ David Wald wald-david@yale.UUCP waldave@yalevm.bitnet wald-david@cs.yale.edu "A monk, a clone and a ferengi decide to go bowling together..." ============================================================================