www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - What does dual-context mean?

reply wjoe <wjoe example.com> writes:
Hello,

what's a dual context as in the deprecation message?

```d
struct MockFile {
   [...]

   void writef(alias fmt, A...)(A args) { // Deprecation: function 
'writef': function requires a dual-context, which is deprecated
     import std.format: format;
     write(format!fmt(args));
   }

   [...]
}

unittest {
   auto f = MockFile();
   immutable fmt = "%d";
   f.writef!fmt(0); // instatiated from here
}
```
Mar 01 2022
parent reply Paul Backus <snarwin gmail.com> writes:
On Tuesday, 1 March 2022 at 14:51:47 UTC, wjoe wrote:
 Hello,

 what's a dual context as in the deprecation message?
It means you have a struct or class member function that accesses its calling context via a template alias parameter. See this bug report for more information: https://issues.dlang.org/show_bug.cgi?id=5710
Mar 01 2022
parent wjoe <wjoe example.com> writes:
On Tuesday, 1 March 2022 at 17:58:24 UTC, Paul Backus wrote:
 On Tuesday, 1 March 2022 at 14:51:47 UTC, wjoe wrote:
 Hello,

 what's a dual context as in the deprecation message?
It means you have a struct or class member function that accesses its calling context via a template alias parameter. See this bug report for more information: https://issues.dlang.org/show_bug.cgi?id=5710
That makes sense. Reading the bug report was really helpful. Thanks.
Mar 02 2022