Discussion Thread: DIP 1028--Make @safe the Default--Final Review
Steven Schveighoffer
schveiguy at gmail.com
Tue Apr 7 21:03:02 UTC 2020
On 4/6/20 11:35 AM, aliak wrote:
>> e.g:
>>
>> static if(someBool)
>> return x;
>> return y; // error statement not reachable
>>
>> inout int[] arr;
>> writeln(arr); // OK
>> writeln(arr.filter!(a => a %5 == 0)); // Error: only parameters or
>> stack based variables can be inout
>
> I'm not sure those are technically sound. Maybe more incomplete
> implementations of the features?
The issue is that filter returns a wrapper type that contains the
original range. Since inout(int)[] is really the only working inout
range in existence, it needs to be stored that way. But the compiler
disallows it. So you see weird problems like this.
-Steve
More information about the Digitalmars-d
mailing list