ceylon/ceylon-spec — Issue #157: Define ** operator in terms of Exponentiable interface 
Author: tombentley
Created: 2012-02-01 20:17:30+00:00
State: open

The power operator (`**`) should be defined in terms of a separate interface (`Exponentiable`), instead of `Numeric`. There are several reasons for this:

* The current definition of power requires that the exponent is of the same type as the base. In some cases it makes much more sense (and is much simpler to implement) if the exponent can be of a different type (e.g. `Decimal` and `Whole` should support `Integer` exponents).
* There are things which would benefit from the other `Numeric` operators, but don't have a suitable (or realistically implementable) definition of `power()`. Consider implementing a `Rational` class.

We also need to consider in more detail what should be specified to happen when the result cannot be represented as a value of the result (base) type. Having control of the type of the exponent helps a lot, but isn't a complete solution (e.g. `2**-1` should presumably throw something). However some types have support for a special value (`-1.0**0.5` returns NaN).