So what does (inout int = 0) do?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 15 06:08:49 PDT 2016


On 4/15/16 8:59 AM, Nick Treleaven wrote:
> On Friday, 15 April 2016 at 04:23:29 UTC, Jonathan M Davis wrote:
>> Certainly, there have been a few times that it's come up in D.Learn
>> when folks ask what the heck it is, so there should be a few posts
>> floating around with an explanation. This is the only useful post that
>> I could find in a quick search though:
>>
>> http://forum.dlang.org/post/mh68p8$2p56$1@digitalmars.com
>
> He says:
>> Alternatively, you could have the lambda take an R as a parameter. Or
>> fix the semantics ...
>
> Assuming it works OK, that seems much cleaner:
>
> (R r)
> {
>      if (r.empty) {}
>      ...
> }

That makes other unittests fail (those with noncopyable ranges).

Overall we really need to spend some time on making Phobos simpler and 
better. The mishmash of styles and variable quality of contributions has 
slowly been gnawing at the sheer quality of the code.


Andrei



More information about the Digitalmars-d mailing list