Nicer syntax for constructors
aberba
karabutaworld at gmail.com
Tue Nov 20 09:29:20 UTC 2018
On Sunday, 18 November 2018 at 19:52:48 UTC, Trailzz wrote:
> On Sunday, 18 November 2018 at 19:47:26 UTC, Jacob Carlborg
> wrote:
>> this(int a, int b)
>> {
>> static foreach (name ;
>> ParameterIdentifierTuple!(__ctor))
>> __traits(getMember, this, name) = mixin(name);
>> }
>> }
>
> This is still very clunky and hard to understand.
I'm not sure if you get it but to understand some D code, there's
some amount of language features you need to know about first
like mixins, stuff in std.traits and what they do... and CTFE...a
few others too. Otherwise, D code might look very weird to you.
But once you get it, you'll smile to D code for its modelling
power. The combination of these features can be mentally tasking
if you don't understand each of them.
I'll recommend the "Programming in D" book if you haven't read it
already (http://ddili.org/ders/d.en/index.html).
"I can do anything! with D."
More information about the Digitalmars-d
mailing list