So what does (inout int = 0) do?

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


On 4/15/16 4:08 PM, Andrei Alexandrescu wrote:
> On 04/15/2016 04:03 PM, Steven Schveighoffer wrote:
>> I have a way to make this work. This is actually the most major sticking
>> point in inout.
>>
>> The only correct thing is to keep is that globals/static variables
>> cannot be typed inout.
>
> Another special case? The only correct thing is to simplify the language
> to everybody's benefit. -- Andrei
>

This is not a special case any more than disallowing access of shared 
data from a pure function is a special case.

In fact, you could allow inout variables as static or globals, but just 
couldn't copy them to local inout variables (except full value types).

The point is that between 2 different calls to inout, the wrapper means 
something different. A global/static persists between calls.

-Steve


More information about the Digitalmars-d mailing list