Post-ctor ctor

Jonathan M Davis jmdavisProg at gmx.com
Mon Aug 8 13:41:50 PDT 2011


> On 8/8/11 6:08 AM, Andrei Alexandrescu wrote:
> > On 8/7/11 1:16 PM, Andrej Mitrovic wrote:
> >> struct Foo
> >> {
> >> int a;
> >> int b;
> >> int c;
> >> int d;
> >> }
> > 
> > Just define a mixin and use it:
> > 
> > this(int a, int b, int c, int d) {
> > mixin(initFromParameters());
> > ...
> > }
> 
> There is currently no »legal« way to get the parameter names in D (other
> than parsing the .stringof output for the function type, which is not
> guaranteed to work, as far as I know), so I don't see how this could be
> implemented. Did I miss something obvious?

In this particular example, what goes in initFromParameters is specific to Foo 
anyway. So, you'd have to write it by hand regardless.

- Jonathan M Davis


More information about the Digitalmars-d mailing list