DIPs icon indicating copy to clipboard operation
DIPs copied to clipboard

proposal written

Open vporton opened this issue 5 years ago • 6 comments

vporton avatar Dec 31 '18 06:12 vporton

Oops, I always forget that code comments should be aimed below, not above the code intended. My lines are off-mark, sorry.

dukc avatar Jan 07 '19 11:01 dukc

Take a look at my comment here: https://forum.dlang.org/post/[email protected]

D requires the mixin keyword to appear in every place that it occurs so that the developer knows when a mixin is occuring. If you provide a feature that lets you mixin code using an alias rather than a mixin, now the developer doesn't know when code is being mixed in unless they look at the implementation of EVERY SINGLE function call. This makes it a nightmare to read code and maintain it.

marler8997 avatar Jan 19 '19 03:01 marler8997

I was supposed to acknowledge this PR when it was submitted. Apologies for forgetting. I'm getting ready to pull two older PRs out of the queue very soon, but it will still be a while before I get to this. Please keep up the draft review. Thanks!

mdparker avatar Jan 30 '19 12:01 mdparker

@vporton Please edit the status field of the DIP to "Draft". Thanks!

mdparker avatar Feb 11 '19 14:02 mdparker

Done

vporton avatar Feb 11 '19 14:02 vporton

I have to say, that I want a better rationale (or the alternatives section I already mentioned). If I want to instantiate many mixins with common arguments, I can already do that:

import std.stdio, std.meta;

  mixin template A(int x, float y) {
    float memberA = x + y;
  }
  mixin template B(int x, float y) {
    float memberB = x - y;
  }

alias ourArguments = AliasSeq!(1, 2.0);

struct Test {
  // put two mixins into Test
  mixin A!(ourArguments);
  mixin B!(ourArguments);
}

void main()
{	writeln(Test.init.memberA, " ", Test.init.memberB);
}

dukc avatar Feb 27 '19 19:02 dukc