Re: mixed in struct constructor is ignored when another (non mixed in) constructor is specified

2018-02-26 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 26 February 2018 at 14:42:58 UTC, Adam D. Ruppe wrote: On Monday, 26 February 2018 at 14:38:22 UTC, ParticlePeter wrote: This cool, I didn't know that we can name mixins when instantiating but also never taught that there could be any purpose for naming. Works, thanks. oh yes,

Re: mixed in struct constructor is ignored when another (non mixed in) constructor is specified

2018-02-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 February 2018 at 14:38:22 UTC, ParticlePeter wrote: This cool, I didn't know that we can name mixins when instantiating but also never taught that there could be any purpose for naming. Works, thanks. oh yes, there's a lot of cool things with mixin. You might want to skim my

Re: mixed in struct constructor is ignored when another (non mixed in) constructor is specified

2018-02-26 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 26 February 2018 at 14:02:56 UTC, Adam D. Ruppe wrote: On Monday, 26 February 2018 at 12:30:24 UTC, ParticlePeter wrote: Is this expected behavior? yes sort of, but there are bugs associated with it too... I wrote about this in the "Tip of the Week" section here before

Re: mixed in struct constructor is ignored when another (non mixed in) constructor is specified

2018-02-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 February 2018 at 12:30:24 UTC, ParticlePeter wrote: Is this expected behavior? yes sort of, but there are bugs associated with it too... I wrote about this in the "Tip of the Week" section here before http://arsdnet.net/this-week-in-d/2016-feb-07.html there's a workaround

Re: mixed in struct constructor is ignored when another (non mixed in) constructor is specified

2018-02-26 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 26 February 2018 at 13:09:40 UTC, ParticlePeter wrote: Thanks for clarification, unfortunately your suggestion doesn't work. Since when is alias this = something; supposed to work? alias Common.this this; doesn't work as well and following also not: struct Baz { Foo foo; alias

Re: mixed in struct constructor is ignored when another (non mixed in) constructor is specified

2018-02-26 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 26 February 2018 at 12:47:48 UTC, Jonathan M Davis wrote: On Monday, February 26, 2018 12:30:24 ParticlePeter via Digitalmars-d-learn wrote: mixin template Common() { private int m_member; this( int m ) { m_member = m; } } struct Foo { mixin Common; } struct Bar { mixin

Re: mixed in struct constructor is ignored when another (non mixed in) constructor is specified

2018-02-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 26, 2018 12:30:24 ParticlePeter via Digitalmars-d-learn wrote: > mixin template Common() { >private int m_member; >this( int m ) { m_member = m; } > } > > struct Foo { >mixin Common; > } > > struct Bar { >mixin Common; >this( int m, float n ) { m_member = m

mixed in struct constructor is ignored when another (non mixed in) constructor is specified

2018-02-26 Thread ParticlePeter via Digitalmars-d-learn
mixin template Common() { private int m_member; this( int m ) { m_member = m; } } struct Foo { mixin Common; } struct Bar { mixin Common; this( int m, float n ) { m_member = m * n; } } auto foo = Foo(1); // ok auto b_1 = Bar( 1, 2 ); // ok auto b_2 = Bar( 3 ); // Error: