What's wrong with this alias?

Ali Çehreli acehreli at yahoo.com
Thu Apr 26 18:03:06 UTC 2018


On 04/26/2018 10:56 AM, Dr.No wrote:

 > class C
 > {
 >
 >      void error(A...)(string fmt, A args)
 >      {
 >          import report : error;
 >          reportedAnyError = true;
 >          error(fmt, args);
 >      }
 >      alias warning = report.warning;
 > }
 >
 >
 > I got this:
 >
 > Error: undefined identifier report.warning

If that really is the code, you're forgetting to import report in that 
scope. Otherwise, that kind of alias works at least in this simple case:

void foo(A...)(A a) {
     import std.stdio;
     writeln(a);
}

alias bar = foo;

void main() {
     bar(42, "hello");
}

Ali



More information about the Digitalmars-d-learn mailing list