that is bug?
Patrick Schluter
Patrick.Schluter at bbox.fr
Sun Apr 8 16:47:59 UTC 2018
On Sunday, 8 April 2018 at 10:03:33 UTC, kdevel wrote:
> On Sunday, 8 April 2018 at 07:22:19 UTC, Patrick Schluter wrote:
>>> You may find an in-depth discussion of the C++ case in
>>>
>>> https://stackoverflow.com/questions/7499400/ternary-conditional-and-assignment-operator-precedence
>>
>> My formulation was ambiguous, it is the same precedence as the
>> link says. The link also says that's it's right to left
>> evaluation. This means that for expression:
>>
>> a ? b = c : d = e;
>>
>>
>> right to left evaluation will make the = e assignment higher
>> priority than the b = c assignment or the ternary even if they
>> have the same priority level.
>
> To summarize: C++ works as expected and C prevents the
> assigment because the conditional operator does not yield an
> l-value:
Exactly
Now, the only thing is to clearly define what it is in D, as
apparently it is neither the C++ nor the C behaviour. The old
precedence table on the D wiki seems to say it is like C, but the
example of that thread seems to show it's not.
More information about the Digitalmars-d
mailing list