D Logic bug
Steven Schveighoffer
schveiguy at gmail.com
Fri Oct 12 13:15:22 UTC 2018
On 10/12/18 6:06 AM, Kagamin wrote:
> On Thursday, 11 October 2018 at 23:17:15 UTC, Jonathan Marler wrote:
>> I had a look at the table again, looks like the ternary operator is on
>> there, just called the "conditional operator". And to clarify, D's
>> operator precedence is close to C/C++ but doesn't match exactly. This
>> is likely a result of the grammar differences rather than an intention
>> one. For example, the "Conditional operator" in D actually has a
>> higher priority than an assignment, but in C++ it's the same and is
>> evaluated right-to-left. So this expression would be different in C++
>> and D:
>>
>> a ? b : c = d
>>
>> In D it would be:
>>
>> (a ? b : c ) = d
>>
>> And in C++ would be:
>>
>> a ? b : (c = d)
>
> That's https://issues.dlang.org/show_bug.cgi?id=14186
Wow, interesting that C precedence is different from C++ here.
-Steve
More information about the Digitalmars-d
mailing list