octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: undefined compound chaining behavior


From: Hossein Sajjadi
Subject: Re: undefined compound chaining behavior
Date: Fri, 13 Jun 2014 10:03:03 +0330

On 6/13/14, Stefan Seefeld <address@hidden> wrote:
> On 2014-06-12 21:24, Hossein Sajjadi wrote:
>> Again we analyse the expression
>> a=1
>> a+=(a+=4)
>> It is shown that the operator in both langauges is the same.
>
> Even if you can show that operator+= is the same in both, that doesn't
> mean that the ternary expression "a+=a+=4" maps from Octave straight to
> C++. In fact, as others have said, such compound expressions are broken
> up, so the C++ compiler never sees this as a single expression, but
> rather as two binary ones (with a temporary, just as Jordi pointed out.)
>
> Thus, these expressions are in fact not equivalent. (You could think of
> it as Octave injecting synthetic sequence points, if that helps.)
>
>         Stefan
>
> --
>
>       ...ich hab' noch einen Koffer in Berlin...
>
>


Even if subexpressions is broken up ,the result may be different
depends on different conditions,since evaluations in C++ are
unsequenced.
I expressed that with a figure.

-Hossein

Attachment: operator.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]