Comments (7)
To be clear, we already have a method called pow
that does this - it's just that there isn't any syntax sugar for having the compiler translate a binary operator to that method call. I think you already know this, I just wanted to be clear for anyone reading along.
I wouldn't be opposed to such a change.
If we do this, I think the best choice for the operator is probably **
- we can't/shouldn't use ^
because it already has another meaning in Pony (it's the ephemeral type indicator).
from rfcs.
@SCKelemen Yes. The syntatic sugar is "xor". Example: https://playground.ponylang.io/?gist=19f5ff394234d6e19ec5bcd1b66ea9d0
from rfcs.
pow
is only defined on FloatingPoint
, as well as powi
which are implemented using http://llvm.org/docs/LangRef.html#llvm-pow-intrinsic and http://llvm.org/docs/LangRef.html#llvm-powi-intrinsic.
There is no pow
in C or C++ as well that operates on integer types. it is only defined on float, double and long double. (This sheds some light on the why: https://stackoverflow.com/questions/2398442/why-isnt-int-powint-base-int-exponent-in-the-standard-c-libraries)
So there is no easy way to implement this without casting, if you don't write it completely in pony.
from rfcs.
Maybe, if this is going to be implemented, Exponentiation by Squaring is a good candidate.
from rfcs.
I'm fine if POW is float only by necessity. A software implementation of it for integers would not be needed, but it would be nice.
from rfcs.
So, is there an XOR operator, then?
from rfcs.
I suggest change the current ephemeral type indicator (^) to another like # or whatever
motivation: use of ^ to exponentiation
languages and others that use ^ as exponentiation: Haskell, Julia, Matlab, R, Lua, Google, calculators
from rfcs.
Related Issues (20)
- Create RFC for collection initializers HOT 2
- #suggest Add uniform coding
- #suggestion Infix operators grouping and "not match" HOT 5
- "not match" and "not if" HOT 2
- Reference consumption and field extraction
- Request: Use primitives methods as lambda calls HOT 3
- Request: Add pipeline operator HOT 11
- Hung TCPConnection can interfere with Pony runtime shutdown HOT 1
- Changes to Auth implementation HOT 7
- Mark RFC repository as a release with any implemented features HOT 1
- Expand or extract logging package from stdlib HOT 3
- Missing mechanism to pass/receive struct values into/from FFI C functions HOT 9
- [stdlib] Add an option for thousands separator to package "format"
- Syntax sugar to assigning a constructor argument to an instance variable and to add the keyword this (or self) HOT 3
- implement cond from Elixir as clean alternative to if / elseif / else HOT 9
- Incorrect division by 0 (1 / 0 -> ∞, in Pony 1 / 0 == 0) HOT 1
- Improve Range and Reverse
- Add StdStream error reporting mechanism HOT 3
- access symbol of private fields is wrong HOT 1
- proposal syntax else ... then for else keyword in conditional branches HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rfcs.