Thread overview
[Issue 19530] New proposed syntax for mixins
Dec 31, 2018
Neia Neutuladh
Dec 31, 2018
Adam D. Ruppe
Dec 31, 2018
Victor Porton
Dec 31, 2018
Adam D. Ruppe
December 31, 2018
https://issues.dlang.org/show_bug.cgi?id=19530

Neia Neutuladh <dhasenan@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dhasenan@gmail.com
         Resolution|---                         |INVALID

--- Comment #1 from Neia Neutuladh <dhasenan@gmail.com> ---
Proposals like this should go through the DIP process -- see https://github.com/dlang/DIPs/blob/master/PROCEDURE.md

That should ensure that, at a minimum, your proposal is described thoroughly enough to understand.

--
December 31, 2018
https://issues.dlang.org/show_bug.cgi?id=19530

Adam D. Ruppe <destructionator@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator@gmail.com

--- Comment #2 from Adam D. Ruppe <destructionator@gmail.com> ---
You can just define a third template that mixes in the first two.

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

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

mixin template composite(int x, float y) {
        mixin A!(x, y);
        mixin B!(x, y);
}

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


That works today.

--
December 31, 2018
https://issues.dlang.org/show_bug.cgi?id=19530

--- Comment #3 from Victor Porton <porton@narod.ru> ---
This does not solve my problem.

I want the possibility to _selectively_ (at my disposal, that is both or only A or only B) add mixins A or B without the necessity to pass template parameters two times. Your example does not solve this problem.

--
December 31, 2018
https://issues.dlang.org/show_bug.cgi?id=19530

--- Comment #4 from Adam D. Ruppe <destructionator@gmail.com> ---
You can also save template argument lists as a separate alias and reuse them.

// save the args as a new name to reuse
import std.meta;
alias MyArgs = AliasSeq!(1, 2.0);

struct Test {
        mixin A!MyArgs;
        mixin B!MyArgs;
}

--