So what does (inout int = 0) do?

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 15 13:11:15 PDT 2016


On 4/15/16 4:03 PM, Andrei Alexandrescu wrote:
> On 04/15/2016 03:44 PM, Steven Schveighoffer wrote:
>>
>> I assure you, these limitations were self-imposed. I insisted on them,
>> without realizing that they would cause problems with generic code. I
>> thought they would be good "lint" detection.
>>
>> https://issues.dlang.org/show_bug.cgi?id=3748
>
> Problem is we could have other problems once we fix those. As you just
> showed, it has already happened.

If you look at the core of what inout actually is (a type modifier 
placeholder), we can simplify how to think about it, and how to 
implement it. These "requirements" were just extra helpful things that 
would flag valid, but (naively assumed) pointless code. Turns out, 
templates generate lots of pointless code (that is typically optimized 
away in the type system or the optimizer).

I hope to make this clear in my talk at dconf.

> We should really do away with the cowboy style of designing language,
> which sadly Walter and I have been guilty of too often in the past. The
> slow but sure accretion of complexity of inout is a textbook example of
> where that leads.

I actually agree, someone with as little experience as I had should not 
have been listened to when making such a feature :)

If I could do it over again, I would still want this feature, but 
obviously, we could make sane simple rules for it. They are actually 
quite easy to understand.

-Steve


More information about the Digitalmars-d mailing list