On Mon, 23 Jun 2014 14:20:32 -0400, bearophile <[email protected]> wrote:

Gary Willoughby:

As another dev said a template or mixin can be used for this.

I don't think a template/mixin can replace that sufficiently well, because you also often want to put some code inside the constructor.

The mixin does not have to generate a whole function, it can just generate the assigns inside a ctor.

I'm envisioning something like this:

class C
{
   int a;
   int b;
   int c;
   this(int a, int b, int c)
   {
      mixin(ctorAssigns); // this.a = a; this.b = b; this.c = c;

      // other code
   }
}

-Steve

Reply via email to