Path: utzoo!attcan!uunet!husc6!bbn!rochester!pt.cs.cmu.edu!sei!sei.cmu.edu!firth From: firth@sei.cmu.edu (Robert Firth) Newsgroups: comp.lang.c Subject: Re: Unnecessary Macros (was Re: Unnecessary Parenthesis) Message-ID: <7378@aw.sei.cmu.edu> Date: 17 Oct 88 17:34:39 GMT References: <2089@ssc-vax.UUCP> <441@kaon.uchicago.edu> <1401@devsys.oakhill.UUCP> <716@accelerator.eng.ohio-state.edu> <8644@smoke.ARPA> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu (Robert Firth) Organization: Carnegie-Mellon University, SEI, Pgh, Pa Lines: 29 In article <716@accelerator.eng.ohio-state.edu>, rob@kaa.eng.ohio-state.edu (Rob Carriere) writes: [The need for a maintainable and efficient way to write things like y := sin(x)^2 +1.7 ] I agree fully with Mr Carriere that most of the suggestions for hand optimising this kind of thing are unworkable. Scientific programs typically contain not simple statements like the above, but statements that run over three or four lines, full of sin(x)^n, sin(x)^(n-1), 2*sin(x-d)*cos(y+d), and so on, and on, and on. These formulae have been laboriously copied from a reference book or article, and they are completely unmaintainable unless they follow as closely as possible the original form. In my experience, even something as simple as multiplying two polynomials and simplifying the result can take an hour or more to check thoroughly. Let the compiler do the work, please. As a corollary: use a language sufficiently powerful that you can give the compiler enough information to enable it to do the work. (Aside: I stuffed the above expression into an Algol-60/Vax compiler, and duly got MOVF x,R0 BSBW sin MULF2 R0,R0 ADDF3 #1.7,R0,y )