www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19530] New: New proposed syntax for mixins

https://issues.dlang.org/show_bug.cgi?id=19530

          Issue ID: 19530
           Summary: New proposed syntax for mixins
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: porton narod.ru

The programmer sometimes needs to instantiate mixin templates with the same
arguments repeatedly, like:

mixin template A(int x, float y) {
  // ...
}

mixin template B(int x, float y) {
  // ...
}

I propose to shorten the above code with the following syntax:

template composite(int x, float y) {
  mixin A {
    // ...
  }
  mixin B {
    // ...
  }
}

// ...

struct Test {
  mixin composite(1, 2.0);
}

--
Dec 30 2018