arithmetic exponentiation operator proposal #1835
Replies: 7 comments
-
|
Be careful, though, that Related: the |
Beta Was this translation helpful? Give feedback.
-
Indeed. With this concern, the operator could be potentially modified to |
Beta Was this translation helpful? Give feedback.
-
|
|
Beta Was this translation helpful? Give feedback.
-
|
Does this really need to be an operator, rather than, say, a standard library function? Is this operation common enough to warrant a dedicated syntax (and requiring everyone to learn that syntax)? |
Beta Was this translation helpful? Give feedback.
-
This is a fair question. But personally, I would much rather have an operator than a function call, mainly to not have to append |
Beta Was this translation helpful? Give feedback.
-
|
FYI, moving from an issue to a discussion. |
Beta Was this translation helpful? Give feedback.
-
|
This should be done with a math std library. It shouldn't be done as language feature. Carbon as a container language shares the same philosophy with c++. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I propose that syntax and functionality for exponentiation is implemented. Currently, if you want to raise some number
xto a power of 2, you must dox * x. This is fine if you only want to raisexto itself once. But, if there is ever a case where you want to raisexto a power greater than 2, it could get ugly quickly. The operator would be like Python's exponentiation operator, which is**. Operator overloading for this could be implemented usingRaiseandRaiseWith(U)orExponentandExponentWith(U)interfaces.With this operator, raising
xto a power of 3 could look likex ** 3instead ofx * x * x.Beta Was this translation helpful? Give feedback.
All reactions