Parenthesis around if/for/while condition is not necessary
Jacob Carlborg
doob at me.com
Sat Jun 23 08:07:23 UTC 2018
On 2018-06-23 03:27, aedt wrote:
> for line in stdin.lines() {}
>
> if condition {}
>
> while condition {}
>
> for init; condition; op {}
>
>
> What's the rationale of keeping the requirement that the condition of
> if/for/while must be wrapped with a parenthesis (other than keeping
> parser simple)? Modern languages have already dropped this requirement
> (i.e. Rust, Nim) and I don't see any reason not to do so.
For the parentheses to be optional I think the curly brace need to be
mandatory, or perhaps force a newline after the condition. I don't see
how this would be any better. You're trading one set of required
punctuational characters for another set. This would also take D one
step further away from the C family of languages.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list