Unnecessary Macros (was Re: Unnecessary Parenthesis)
Barnacle Wes
wes at obie.UUCP
Fri Oct 7 12:20:32 AEST 1988
In article <8078 at haddock.ima.isc.com> karl at haddock.ima.isc.com (Karl Heuer) writes:
> z = square(*p++) + square(getchar());
> I dislike the original macro, but the fact remains that there is no good way
> to write this in C.
In article <8590 at smoke.ARPA>, gwyn at smoke.ARPA (Doug Gwyn ) replies:
| One wonders whether this is much of a problem.
| (Note that the example is silly.)
|
| There have been many occasions when I've needed the sum of two squares,
| but I've never felt the need for the ability to define a "square" macro
| in order to compute that.
This code fragment was taken from a function that calculates the true
wind speed and heading based on the apparent wind speed and angle, and
the speed and course of a sailboat. Note the last line:
/*
* Now return the true wind vector to normal coordinates.
*/
tw.heading = atan2(tw.ycomp, tw.xcomp);
tw.speed = sqrt((tw.ycomp * tw.ycomp) + (tw.xcomp * tw.xcomp));
This seems the obvious way to perform such a calculation to me. If
any of you net.c.programmers really can't stand this style, please tell
me why!
--
{hpda, uwmcsd1}!sp7040!obie!wes
"How do you make the boat go when there's no wind?"
-- Me --
More information about the Comp.lang.c
mailing list