Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!rpi!itsgw!steinmetz!davidsen From: davidsen@steinmetz.ge.com (William E. Davidsen Jr) Newsgroups: comp.lang.c Subject: Re: C optimizer Keywords: C pure function optimization Message-ID: <13134@steinmetz.ge.com> Date: 14 Feb 89 15:14:56 GMT References: <515@larry.UUCP> <9648@smoke.BRL.MIL> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: General Electric CRD, Schenectady, NY Lines: 29 In article <9648@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: | This is an interesting issue. In traditional C implementations, since | there was no guarantee that the functions wouldn't have side effects ... | ... ... a sufficiently | clever optimizer could take advantage of the fact that they're known to | be so-called "pure" functions to avoid calling them multiple times with | the same argument. I don't know of any implementations that perform | this particular optimization, but I suspect the supercomputer folks | will be doing it. I agree. One solution would be to provide a keyword, perhaps something like 'pure' or 'deterministic', which would indicate that a procedure always returns the same value for a set of given arguments. Note that this is not the same thing a "no side effects," my intent is only that a second call with the same arguments would not change the side effects (such as saving one of the arguments, etc). There must be a good mathmatical term for this, 'pure' has too many overloaded meanings, and 'deterministic' is far too long. I am not sure that having the compiler "know about" library functions is a good idea, since the user could provide functions with identical names if the compile were to be used in a non-hosted application. -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me