On Monday, 17 May 2021 at 14:35:51 UTC, Steven Schveighoffer wrote:
On 5/17/21 9:47 AM, jmh530 wrote:
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))();
}
```

The feature is deprecated in its current form. The issue as I understand it (i.e. very little) is that compilers other than DMD could not use this same way to implement dual contexts, and so they could not have the feature. This means that valid code in DMD would not compile on GDC or LDC.

The way forward was to deprecate the mechanism used to implement it for DMD, and at some point tackle it in a backend-agnostic way.

Personally, I don't know why we can't fix it so that it's portable, but I understand so little about compilers that I've pretty much stayed out of it. The feature is very much needed.

-Steve

The dual context that warning is referring to is vthis2, which the gdc maintainer struggle to implemented for the gdc compiler. A correct fix involves templates having their own context.

-Alex

Reply via email to