Tsoding - How Not to Market Your Language Features

Timon Gehr timon.gehr at gmx.ch
Wed Apr 2 20:00:54 UTC 2025


On 4/2/25 19:34, Walter Bright wrote:
> On 4/2/2025 8:16 AM, Timon Gehr wrote:
>> Can you show the code that you mean or give a more accurate time 
>> stamp? I only see the _delegate's_ parameter `i` at 1:19:41, which 
>> does not lead to shadowing, as the only actual parameter in scope 
>> within `opApply` is `dg`.
> 
> The foreach of an opapply is rewritten by dmd into a delegate. If the 
> shadowing is not detected, this would be why.
> ...

Well, there is this case, but I don't find anything like this in the 
video near 1:20:00:

```d
struct S{
     int opApply(int delegate(int) dg){
         foreach(k;0..10)
             if(auto r=dg(k))
                 return r;
         return 0;
     }
}


void foo(int i){
     foreach(i;S()){} // not detected
}

void main(){
     foo(2);
}
```



More information about the Digitalmars-d mailing list