As a Mathematician I would like:

Stewart Gordon smjg_1998 at yahoo.com
Fri Jun 29 17:54:59 PDT 2007


"Stephen Montgomery-Smith" <stephen at math.missouri.edu> wrote in message 
news:f63hjf$krv$1 at digitalmars.com...
> 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?).

Not sure about this myself.  BASIC uses ^.  I guess we could use ↑ - except 
that using Unicode characters is still a problem for some of us.  There are 
at least two precedents for this: ZX Spectrum Basic (though really only by 
being the Spectrum's glyph for '^') and Knuth's up-arrow notation

http://en.wikipedia.org/wiki/Knuth%27s_up-arrow_notation

though that said, I don't know whether one inspired the other.

> 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 agree that this definition makes more sense and we ought to have it, but 
I'm not sure about altering the current % operator in D.  OUAT I proposed 
adding an operator for this:

http://tinyurl.com/2vpf7q

Stewart. 




More information about the Digitalmars-d mailing list