Talk:Exponentiation order

From Rosetta Code
Revision as of 23:29, 23 March 2014 by rosettacode>Gerard Schildberger (→‎Functions: other examples...)

Functions

So it has to be an operator? A "pow" function is not allowed? --Mwn3d (talk) 19:00, 18 March 2014 (UTC)

No, and then no.   Er, I mean, it doesn't have to be, and yes, POW is allowed if there isn't an operator for exponentiation.   I have no qualms about including the POW function in any case.   But a function has no misinterpretation of what order the exponentiation is in, as in   pow(x,y).   Of course, you could write   pow(x, pow(y,z))   (or something similar, depending on you or your language interpret the operator) to show this task's intention, but there is no ambiguity in function calls.   Whereas,   5**3**2   is swimming with vagueness. -- Gerard Schildberger (talk) 19:09, 18 March 2014 (UTC)
Why? Somehow people don't find "a - b - c" swimming in vagueness. And in the languages I know, if there's an pow operator, 5**3**2 is always interpreted as 5**(3**2), just like in maths. --Ledrug (talk) 03:31, 19 March 2014 (UTC)
I also don't believe that   a-b-c   is vague, but then, subtraction isn't what is being discussed.   The why is simple to explain:   because not all computer languages treat multiple (or chained) exponentiation the same.   5**3**2   is not always interpreted as   5**(3**2).   If that expression would be treated universally the same, there wouldn't be a need for this Rosetta Code task.   I'm not going to pontificate whether or not which manner of evaluation is correct; the main thing I'm interested is how various computer languages evaluate the expression, and what value is produced.   It's not a matter of doing it "the right way", the way that a computer language does it, is the way it is.   To quote my niece, Jackie, it is what it is. -- Gerard Schildberger (talk) 03:56, 19 March 2014 (UTC)
"If that expression would be treated universally the same, there wouldn't be a need for this Rosetta Code task." Can you give an example of a place where it is not right associative? Because I precisely have trouble figuring out why there's need for this Rosetta Code task. --Spoon! (talk) 09:06, 19 March 2014 (UTC)
The existing examples show a difference. The first Perl 6 example shows that 5**3**2 = 5**(3**2) and the REXX example shows that 5**3**2 = (5**3)**2. --Mwn3d (talk) 13:05, 19 March 2014 (UTC)
Likewise, a - b - c is also "swimming in vagueness" if you might or might not be programming in an APL derivative, where pretty much everything is right associative, if I recall correctly. --TimToady (talk) 21:16, 19 March 2014 (UTC)
Which is one reason to show examples.   Without examples of different computer languages, we'd have to resort to researching each computer language to find this information, and in the case of REXX (and probably other language docs), the documentation doesn't mention specifically the result of   a**b**c.   As soon as other REXX "derivatives" (in the sense that they were developed later), APL (+ derivatives), and other computer languages, more differences will show up. -- Gerard Schildberger (talk) 23:29, 23 March 2014 (UTC)

Task necessary?

The task Operator precedence which lists all the precedence and associativity rules for a language exists already. Since the order of "chained" exponentiations is simply determined by the associativity of the exponentiation operator I don't think this task adds any new information. --Andreas Perstinger (talk) 22:49, 23 March 2014 (UTC)