Parenthesis around if/for/while condition is not necessary

Nick Treleaven nick at geany.org
Sun Jul 1 12:02:03 UTC 2018


On Sunday, 24 June 2018 at 23:40:56 UTC, Timoses wrote:
> The others may be rewritten to not have a leading "!" as well, 
> e.g.
>
>> if (!(t1.ty == Tarray && t2.ty == Tarray && needsDirectEq(t1, 
>> t2))
>
> if (t1.ty != Tarray || t2.ty != Tarray || ...)

Yes, but you might make a mistake, and sometimes it makes more 
intuitive sense to read it in a non-minimized form. This type of 
change is also much harder to review. Consider why the change got 
checked into dmd, without it being minimized at the time or in a 
later pull.

C# supports `if !(`.


More information about the Digitalmars-d mailing list