In this example (extracted from
https://digitalmars.com/articles/b68.html), this works:
```
class C {
int a;
int foo(int i) { return i + a; }
}
auto mfp = (C self, int i)=>self.foo(i);
void main(){
auto c = new C;
assert( c.mfp(20)==20);
}
```
but this fails
```
class C {
int a;
i
On Thursday, 8 July 2021 at 22:24:26 UTC, Antonio wrote:
I supossed that ```mfp(c,20)``` and ```c.mfp(20)``` should be
equivalent because UFCS in second example, but it is not... why?
UFCS only works with functions defined at top level, not nested
inside other functions. That's just how it is
On Thursday, 8 July 2021 at 22:24:26 UTC, Antonio wrote:
I supossed that ```mfp(c,20)``` and ```c.mfp(20)``` should be
equivalent because UFCS in second example, but it is not... why?
UFCS does not work for nested functions.
Functions declared in a local scope are not found when
searching fo
On Thursday, 8 July 2021 at 22:24:26 UTC, Antonio wrote:
onlineapp.d(9): Error: no property `mfp` for type `onlineapp.C`
I supossed that ```mfp(c,20)``` and ```c.mfp(20)``` should be
equivalent because UFCS in second example, but it is not... why?
https://dlang.org/spec/function.html#pseudo-
On Thursday, 8 July 2021 at 22:31:49 UTC, Dennis wrote:
On Thursday, 8 July 2021 at 22:24:26 UTC, Antonio wrote:
I supossed that ```mfp(c,20)``` and ```c.mfp(20)``` should be
equivalent because UFCS in second example, but it is not...
why?
UFCS does not work for nested functions.
Functions
On Thursday, 8 July 2021 at 23:31:57 UTC, Antonio wrote:
"It works as described in the manual, not as expected" (from
MySQL haters club :-p) .
Yeah, 50/285 people answering the question "What language
features do you miss?" chose "UFCS for local symbols" in the
[State of D survey
(2018)](htt