[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #51962] "A++" assigns to 'ans' while "A += 1"
From: |
Mike Miller |
Subject: |
[Octave-bug-tracker] [bug #51962] "A++" assigns to 'ans' while "A += 1" and "A = A + 1" do not |
Date: |
Sat, 9 Sep 2017 16:22:30 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 |
Follow-up Comment #7, bug #51962 (project octave):
IMHO redoing the ++ and -- operators to be the same thing as +=1 and -=1 would
not be a good thing and would break some behavior. The ++ and -- operators
currently mimic the C prefix and postfix behavior, which to me is a good and
intentional thing worth keeping.
Specifically, the following postfix behavior would change
>> x = 1;
>> y = x++;
x, y
x = 2
y = 1
>> x = 1;
>> y = (x += 1);
x, y
x = 2
y = 2
I think it would be better to fully document the differences, that "X += 1"
only affects X, while "X++" affects X and also returns a copy of the previous
value of X as a side effect, which may take up a lot of memory depending on
the size of X.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?51962>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #51962] ++ and -- not same as +1 and -1, anonymous, 2017/09/07
- [Octave-bug-tracker] [bug #51962] ++ and -- not same as +1 and -1, Rik, 2017/09/08
- [Octave-bug-tracker] [bug #51962] ++ and -- not same as +1 and -1, Mike Miller, 2017/09/08
- [Octave-bug-tracker] [bug #51962] "A++" assigns to 'ans' while "A += 1" and "A = A + 1" do not, Rik, 2017/09/08
- [Octave-bug-tracker] [bug #51962] ++ and -- not same as +1 and -1, John W. Eaton, 2017/09/08
- [Octave-bug-tracker] [bug #51962] "A++" assigns to 'ans' while "A += 1" and "A = A + 1" do not, Rik, 2017/09/08
- [Octave-bug-tracker] [bug #51962] "A++" assigns to 'ans' while "A += 1" and "A = A + 1" do not, Rik, 2017/09/09
- [Octave-bug-tracker] [bug #51962] "A++" assigns to 'ans' while "A += 1" and "A = A + 1" do not, Michael Godfrey, 2017/09/09
- [Octave-bug-tracker] [bug #51962] "A++" assigns to 'ans' while "A += 1" and "A = A + 1" do not,
Mike Miller <=
- [Octave-bug-tracker] [bug #51962] "A++" assigns to 'ans' while "A += 1" and "A = A + 1" do not, Michael Godfrey, 2017/09/09
- [Octave-bug-tracker] [bug #51962] "A++" assigns to 'ans' while "A += 1" and "A = A + 1" do not, Rik, 2017/09/10
- [Octave-bug-tracker] [bug #51962] "A++" assigns to 'ans' while "A += 1" and "A = A + 1" do not, Mike Miller, 2017/09/10
- [Octave-bug-tracker] [bug #51962] "A++" assigns to 'ans' while "A += 1" and "A = A + 1" do not, Michael Godfrey, 2017/09/10