Should ^^ (opPow) be left- or right-associative?
KennyTM~
kennytm at gmail.com
Sat Dec 5 08:18:19 PST 2009
Currently in D (r283) opPow is left-associative:
import std.stdio;
void main() {
// prints 19683 instead of 7625597484987:
writeln(3.0 ^^ 3.0 ^^ 3.0);
}
But the mathematical convention is a^b^c == a^(b^c).
Languages which the power operator is right-associative (3^3^3==7e12):
- Python, Haskell, Ruby, Perl, Mathematica, Bash.
Languages which the power operator is left-associative (3^3^3==19683):
- Octave/MATLAB, Excel, BASIC.
More information about the Digitalmars-d
mailing list