|
From: | anonymous |
Subject: | [Octave-bug-tracker] [bug #54698] Precedence of call/indexing operator over transpose operator |
Date: | Fri, 21 Sep 2018 11:04:06 -0400 (EDT) |
User-agent: | Mozilla/5.0 (Windows NT 5.1; rv:51.0) Gecko/20100101 Firefox/51.0 |
Follow-up Comment #8, bug #54698 (project octave): I have found the simplest solution! Here is the first 3 rows of the current table of precedence <https://octave.org/doc/v4.4.0/Operator-Precedence.html>: ‘()’ ‘{}’ ‘.’ ‘++’ ‘--’ postfix increment/decrement ‘'’ ‘.'’ ‘^’ ‘**’ ‘.^’ ‘.**’ .... Other rows of the table are truncated because are unrelated to the current discussion. If all of them are assigned the same level of precedence the problem is solved. So all of them should be on the first row: ‘()’ ‘{}’ ‘.’ ‘++’ ‘--’ ‘'’ ‘.'’ ‘^’ ‘**’ ‘.^’ ‘.**’ Now in the expression: A.'.'.'(X)(Y) Because the transpose operator and the call operator have the same level of precedence the expression is executed from left to right. Currently there is a bug about precedence of call/indexing operator over postfix increment/decrement operator that now can be fixed as the current issue. Consider the expression: a = [5 7]; b = a++(2); disp(a) Regarding the current table of precedence it should be evaluated as: a = [5 7]; b = a(2); a(2) = a(2) + 1; disp(a) But it is evaluated as: a = [5 7]; b = a(2) a = a + 1; disp(a) With the proposed modification to the documentation of the precedence table this bug also can be resolved. @Michael Leitner As you I think that "postfix increment and decrement group right to left." is wrong and they group left to right. Your second point about +++a is the same as c++ behavior. You can see this stackoverflow question <https://stackoverflow.com/questions/5236706/what-is-i-increment-in-c>. They have noted that it is related to maximum munching rule. _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?54698> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |