Why UFCS doesn't work with "with" statement?

Lukanian nanaipenero at forum.com
Mon Jun 9 11:39:15 UTC 2025


Why UFCS doesn't work with "with" statement?

```d
struct MyStruct1
{
   int a, b;
   int sum(){
     return a+b;
   }
}

int difference(ref MyStruct1 self)
{
   return self.a-self.b;

}

// in main()

MyStruct1 s = { 1, 2 };

s.difference().writeln; // works fine

with(s){
   sum().writeln;
   difference().writeln; // error: too few arguments, expected 1, 
got 0
}
```



More information about the Digitalmars-d mailing list