Why is D unpopular, redux.

Timon Gehr timon.gehr at gmx.ch
Tue May 24 23:35:57 UTC 2022


On 25.05.22 00:55, Timon Gehr wrote:
> On 24.05.22 19:10, Walter Bright wrote:
>> On 5/24/2022 12:45 AM, Timon Gehr wrote:
>>> No. The correct behavior when a delegate literal outlives captured 
>>> variables is to allocate a closure. This case is not an exception...
>>
>> But it isn't a safety problem, as it won't compile.
> 
> Well, it's still a memory safety problem in @system code, it's just that 
> it's not a soundness issue for @safe.

Actually, that's not even true. The line that does not compile does not 
even have to do anything with the issue. This compiles even with -dip1000:

```d
import std.stdio;

void main()@safe{
     void delegate()@safe[] dgList;
     foreach(i; [1, 2, 3]) {
         immutable b = i;
         dgList ~= { writeln(b); };
     }
     foreach(dg; dgList) dg();
}
```

I.e., this issue is alive and well. It's a memory safety issue in 
@system code and it's a soundness problem for @safe.


More information about the Digitalmars-d mailing list