As a Mathematician I would like:
Stephen Montgomery-Smith
stephen at math.missouri.edu
Fri Jun 29 11:04:31 PDT 2007
If I had two changes I would make to the C programming language, it is
1. Put in an exponentiation operator, a^b or a**b, so that 2**3 is 8.
For a numerics programmer this would be really useful. This is one way
that Fortran really scores over C. I know that there is the pow function
in C, but it always treats the power as a float or double, where if the
power is an integer it should really work differently. Also the
optimization should be able to do clever things with a^2 (i.e. write it
as inline code a*a). Also, using "pow" is just plain ugly. I do
appreciate that a^b and a**b already have meaning in C (the first is
exclusive or, and the second is a*(*b)), but I think that this is
sufficiently worthwhile for numerics programmers that you either find a
whole new symbol, or depreciate the current use of ^ or ** (e.g. one
could insist that the current a**b is always written a* *b - I mean when
does a**b actually ever appear in real code?).
2. a%b has a very definite and unambiguous meaning when a is negative,
and b is positive. The output should be non-negative. This is something
perl has done right. For example (-6)%7 is 1.
I also wrote this at the following url, but maybe this wasn't the right
place to write it:
http://www.prowiki.org/wiki4d/wiki.cgi?DocComments/Lex
More information about the Digitalmars-d
mailing list