Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!amdcad!ames!mailrus!tut.cis.ohio-state.edu!accelerator.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: Unnecessary Macros (was Re: Unnecessary Parenthesis) Message-ID: <716@accelerator.eng.ohio-state.edu> Date: 5 Oct 88 22:42:32 GMT References: <2089@ssc-vax.UUCP> <441@kaon.uchicago.edu> <1401@devsys.oakhill.UUCP> <23@datcon.UUCP> <8577@smoke.ARPA> <8078@haddock.ima.isc.com> <8590@smoke.ARPA> <701@accelerator.eng.ohio-state.edu> <8629@smoke.ARPA> Sender: news@accelerator.eng.ohio-state.edu Reply-To: rob@kaa.eng.ohio-state.edu (Rob Carriere) Organization: Ohio State Univ, College of Engineering Lines: 37 In article <8629@smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >In article <701@accelerator.eng.ohio-state.edu> rob@kaa.eng.ohio-state.edu >(Rob Carriere) writes: >>In article <8590@smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >>>One wonders whether [the inability to define a square macro] is much of a >>>problem. >>How about the following, deep in some inner loop: >>foo = square( sin( x )) + 1.7; > >Another silly example. I can't imagine a real algorithm that would want >this computation in it. If you leave off the ``+1.7'' that was there for decoration anyway, try an FFT. >Most programmers wouldn't have any trouble with > foo = sin(x); > foo = foo*foo + 1.7; > >I agree that an exponentiation operator would be handy, >but a "square" macro doesn't seem to help readability. 1) If you have a text in front of you that says sin(x)^2 + 1.7 (LaTeX notation, not C), then there *is* a problem with the temporary: you have to go back and check it every time you read the statement. If the sin(x) gets more complicated, this just about destroys readability (I've had cases where it took pencil, paper and five minutes of algebra to verify that all the temporaries did what they were supposed to do -- not my definition of high readability) 2) I used the ``square'' macro, because that was the original example. I agree that what is needed is a way of doing small integer powers in general, but that just changes the problem to: why can't I write power( sin(x), 2 ) [1] or some such. Rob Carriere [1] not pow( sin(x), 2). I want something that will become 1 evalution of sin(x) and 1 multiply.