Parenthesis around if/for/while condition is not necessary
Daniel N
no at public.email
Wed Jul 4 08:30:31 UTC 2018
On Monday, 2 July 2018 at 20:28:06 UTC, Seb wrote:
> On Sunday, 1 July 2018 at 12:02:03 UTC, Nick Treleaven wrote:
>> 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 !(`.
>
> and it wouldn't be hard for D to support it too:
> https://github.com/dlang/dmd/pull/8440
> It just requires someone to step up and write the DIP.
Since ! is used to pass template params... I'd rather use it for
parameterized keywords in the same way, for instance:
if!likely(...)
if!unlikely(...)
It would standardize the existing practice of "__builtin_expect".
Also it you really wanted, you could add something like:
if!not(...)
More information about the Digitalmars-d
mailing list