Dechenjm / crack-language

Automatically exported from code.google.com/p/crack-language
Other
0 stars 0 forks source link

Exponentiation operator #127

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
There is currently no exponentiation operator, which makes denoting polynomials 
quite hard, e.g. if x is of type poly we could write

y := x^^3 + 3*x^^2 + 2*x + 1

at the moment we have to write

y := pow(x, 3) + 3*pow(x, 2) + 2*x + 1

which is painful and harder to read.

There are three fairly standard possibilities for an exponentiation operator.

1) ^^ : see D language for example
2) ** : see Python for example
3) ^ : see Julia for example

Number 3 is not possible due to the use of ^ for xor as per C (not the same 
precedence and associativity as exponentiation).

Either 1 or 2 would be extremely useful.

Original issue reported on code.google.com by goodwill...@googlemail.com on 28 Dec 2014 at 4:10

GoogleCodeExporter commented 8 years ago
I have no problem with this in principal, if we're going to do it I'd favor 2 
('**').  As you pointed out, 3 ('^') is not feasible.

Are you interested in attempting to implement this?  I'm unlikely to get to it 
in the foreseeable future.

Original comment by mind...@gmail.com on 28 Dec 2014 at 5:07

GoogleCodeExporter commented 8 years ago
I have no problem with **.

At the moment I'm not quite familiar enough with the crack codebase to 
implement it. But I might give it a go if you could direct me to the relevant 
files. I don't imagine it being too difficult for me to implement.

Original comment by goodwill...@googlemail.com on 28 Dec 2014 at 7:03