Post-ctor ctor

Timon Gehr timon.gehr at gmx.ch
Mon Aug 8 13:26:21 PDT 2011


David Nadlinger wrote:
> 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?
>
> David

Always use structs and classes with exactly 4 fields and always name them (as well
as the constructor arguments) a,b,c,d.


More information about the Digitalmars-d mailing list