Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!nic.MR.NET!shamash!rosevax!ernie.Rosemount.COM!merlyn From: merlyn@ernie.Rosemount.COM (Brian Westley) Newsgroups: comp.lang.c Subject: Re: pure functions are tricky Message-ID: <7267@rosevax.Rosemount.COM> Date: 21 Feb 89 15:39:12 GMT References: <7256@rosevax.Rosemount.COM> <9669@smoke.BRL.MIL> Sender: news@rosevax.Rosemount.COM Reply-To: merlyn@ernie.Rosemount.COM (Brian Westley) Organization: Rosemount Inc., Burnsville, MN Lines: 26 Legend: >>Me >Doug Gwyn >>Now, should it be possible to fold pure functions with constant arguments? >> x = sin(sqrt(2.0)) ; /* turns into simple assignment to a constant? */ > >Sure. Why not?... But then I asked - >>What about pure functions that can only be evaluated at run time, such as a >>function that returns the name of the machine the program is running on? This was my main point: there are functions which return the same results for the same arguments, without side-effects, which can't be folded at compile time if given constant arguments. If such functions are not considered pure, they won't be optimized. If such functions are considered pure, not all pure functions will be foldable into constants. Either you have to tell the compiler which is which, or the compiler has to figure it out (not bloody likely). ----- Merlyn LeRoy #pragma ivory /* 99 44/100% pure */