Andrei Alexandrescu wrote:
Matti Niemenmaa wrote:
Don wrote:
Yes, ^^ hasn't been used for exponentiation before. Fortran used **
because it had such a limited character set, but it's not really a
natural choice; the more mathematically-oriented languages use ^.
Obviously C-family languages don't have that possibility.
Haskell has three exponentiation operators in the standard library: ^,
^^, and **. They are for non-negative integral exponents, integral
exponents, and floating-point exponents respectively.
I wonder whether that's an illustration of the power or of the failure
of function overloading. (Seriously.)
I'm not sure either. I don't speak Haskell, but my guess is that ^ and
^^ were meant to cut out the confusion that would happen if Word32 ^
Word32 (what weird naming conventions Haskell has!) returned an integer
type but Int32 ^ Int32 returned a floating point type.
But why it needs yet another for floating-point exponents, I don't know.
Maybe Haskell supports only IFTI rather than true function overloading.
Stewart.