_aaApply2

Nick Treleaven nick at geany.org
Mon Jul 22 16:32:38 UTC 2024


On Monday, 22 July 2024 at 15:25:32 UTC, IchorDev wrote:
> On Monday, 22 July 2024 at 11:11:53 UTC, Quirin Schroll wrote:
>> The issue is that iteration isn’t `nothrow`, but I don’t know 
>> why. It makes no sense.

See https://issues.dlang.org/show_bug.cgi?id=21236.

> I guess because the function calls an un-marked delegate? I’m 
> not even sure how I’m able to call it in `@safe` code though,

It's @safe for the compiler to generate a call to it if the loop 
body is @safe. If the body wasn't safe, there would be an error 
anyway.

> and yet it supposedly uses the GC just for iteration?

Do you have an example? The following compiles:

```d
void main() @nogc
{
     int[string] aa;
     foreach (k, v; aa)
         assert(v);
}
```



More information about the Digitalmars-d mailing list