Parenthesis around if/for/while condition is not necessary
Basile B.
b2.temp at gmx.com
Sun Jun 24 08:37:40 UTC 2018
On Sunday, 24 June 2018 at 08:30:28 UTC, Jacob Carlborg wrote:
> On 2018-06-23 14:34, Tobias Müller wrote:
>
>> AFAIK the if and else branches in Rust always have to be
>> enclosed in curly
>> braces because of this.
>> I don't remember the exact ambiguity though.
>
> There's an ambiguity between the condition and the body. There
> needs to be some kind of symbol to separate the two. In D,
> that's the closing parenthesis (technically the opening
> parenthesis is not necessary but unbalanced parentheses look
> weird for humans). In Rust it's the opening curly brace.
Yeah, as pointed out at the beginning
https://forum.dlang.org/post/gwxrvrzgycnxwzzszkbr@forum.dlang.org
Despite of the ugliness of the construct the main issue is that a
binary or a relational operator could be missing in this case.
More information about the Digitalmars-d
mailing list