is there a reason declarative style if are allowed, but not while ?

Max Haughton maxhaton at gmail.com
Sun Feb 28 14:46:40 UTC 2021


On Sunday, 28 February 2021 at 14:32:32 UTC, Timon Gehr wrote:
> On 26.02.21 21:32, deadalnix wrote:
>> D allows for this type of constructs:
>> 
>> if (auto foo = bar()) { ... }
>> 
>> I was trying to do something similar with a while loop, but 
>> DMD seems very upset about it. Is there a reason to disallow 
>> the following?
>> 
>> while (auto foo = bar()) { ... }
>> 
>> 
>
>
> I don't think there's any good reason.
>
> Related: https://issues.dlang.org/show_bug.cgi?id=16140
>
> FWIW, note that this works in C++.

The with() issue linked within that bug would be nice - in 
particular I really want trailing with like `{} with (...)` like 
a where clause in Haskell


More information about the Digitalmars-d mailing list