dual-context deprecation

jmh530 john.michael.hall at gmail.com
Mon May 17 13:47:28 UTC 2021


The code below (simplified from my actual problem) generates a 
warning that member function b "requires a dual-context, which is 
deprecated".

However when I look at the list of deprecated features [1], I'm 
not seeing which one this is referring to. Is it a valid 
deprecation?

I could only find this [2] reference to dual-contexts, which 
suggests that the problem relates to passing aliases into member 
functions. Moving it to a member function fixes the problem. 
Alternately, I could make the alias part of Foo's type. My use 
case it is just a little easier structured like this, but I get 
that there are workarounds.

My bigger question is about why it isn't listed more than 
anything. I.e., should I file something in bugzilla.

```d
struct Foo
{
     double a;

     this(double x)
     {
         this.a = x;
     }

     double b(alias inverse)()
     {
         return inverse(a);
     }
}

void main()
{
     auto foo = Foo(2.0);
     auto x = foo.b!(a => (10.0 ^^ a))();
}
```

[1] https://dlang.org/deprecate.html
[2] 
https://forum.dlang.org/thread/mkeumwltwiimkrelgqrr@forum.dlang.org


More information about the Digitalmars-d-learn mailing list