prototyping (oh no! not again??)
Richard A. O'Keefe
ok at goanna.cs.rmit.oz.au
Thu Nov 29 17:25:27 AEST 1990
In article <DAVIS.90Nov28140038 at pacific.mps.ohio-state.edu>, davis at pacific.mps.ohio-state.edu ("John E. Davis") writes:
> Also, what C lacks is something as the fortran ** operator. Why can't this be
> implemented as a binary operator say as x^y.
For the same reason that SIN isn't a unary operator in Fortran, even
though mathematicians use "sin x" in preference to "sin(x)". Let's
face it, Fortran hasn't a MOD operator! (All together now, let's flame
Fortran for not having something as basic as "%".) The answer is:
either you go the APL route of making _everything_ an operator, or you
draw a line somewhere and say "this has the syntax of an operator, that
has the syntax of a function call". That choice has *NO* consequences
for how the implementation works. In this particular case, "^" already
*is* an operator in C, meaning bit-wise exclusive or.
> I am not sure what the pow function does.
Why not check a manual and find out before complaining that C hasn't got
an equivalent of **? In ANSI C, if you have done
#include <math.h>
there is no significant non-syntactic difference between pow() and
<REAL or DOUBLE> ** <INTEGER or REAL or DOUBLE>.
An ANSI C compiler is fully entitled to compile
x = pow(y, 2); /* I _did_ say ANSI! Pre-ANSI needs 2.0 */
as x = y*y;
Is this in the FAQ?
--
I am not now and never have been a member of Mensa. -- Ariadne.
More information about the Comp.lang.c
mailing list