miniscript icon indicating copy to clipboard operation
miniscript copied to clipboard

Consider changing associativity of ^

Open JoeStrout opened this issue 1 year ago • 0 comments

The ^ operator in MiniScript is left-associative. There is no universal standard for this, but right associativity for this is somewhat more common, and the current behavior has surprised at least one user.

Other languages are not very consistent about this: https://codeplea.com/exponentiation-associativity-options

Of the languages surveyed here, 11 are right-associative, and 6 are left-associative. Even handheld calculators don't all agree on this.

https://en.wikipedia.org/wiki/Exponentiation#In_programming_languages says that "most" languages make it right-associative, but notable exceptions are Algol, MATLAB, and Excel, which could all be considered "math-oriented" languages.

So, hmm.

Given all this, I'm inclined to say that it would be better if it were right-associative. The question is, should we risk breaking code by changing the design at this point? I'm not sure.

JoeStrout avatar Jul 26 '24 18:07 JoeStrout