[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: undefined compound chaining behavior
From: |
Mike Miller |
Subject: |
Re: undefined compound chaining behavior |
Date: |
Tue, 10 Jun 2014 08:21:59 -0400 |
On Tue, Jun 10, 2014 at 08:09:40 +0330, Hossein Sajjadi wrote:
> accoring to the manual:
> expr1 op= expr2
> is evaluated as
> expr1 = (expr1) op (expr2)
>
> so the expression
> a=1;
> a+=(a+=4);
>
> should be equivalent to
> a=1;
> a=a+(a=a+4);
>
> but the firt expression results 10 and second results 6
Ok, I understand. I think the best thing you can do to resolve this is
to report a bug [1] requesting that the manual be updated to describe
this behavior of assignment operators more clearly. To be clear, there
is no undefined behavior here, it's just that OP= means that the
left-hand side of the assignment is evaluated when the assignment is
made. So the simple equivalence described in the manual is not correct
if EXPR2 modifies EXPR1 as a side effect.
[1] https://savannah.gnu.org/bugs/?func=additem&group=octave
Thanks,
--
mike
- Re: undefined compound chaining behavior, (continued)
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/06
- Re: undefined compound chaining behavior, Daniel J Sebald, 2014/06/09
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/09
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/09
- Re: undefined compound chaining behavior, Mike Miller, 2014/06/09
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/09
- Re: undefined compound chaining behavior, Mike Miller, 2014/06/09
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/10
- Re: undefined compound chaining behavior, Ben Abbott, 2014/06/10
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/10
- Re: undefined compound chaining behavior,
Mike Miller <=
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/10
- Re: undefined compound chaining behavior, Mike Miller, 2014/06/10
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/10
- Re: undefined compound chaining behavior, Michael Goffioul, 2014/06/10
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/10
- Re: undefined compound chaining behavior, Mike Miller, 2014/06/10
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/10
- Re: undefined compound chaining behavior, Michael D. Godfrey, 2014/06/10
- Re: undefined compound chaining behavior, Hossein Sajjadi, 2014/06/10
- Re: undefined compound chaining behavior, Mike Miller, 2014/06/10