www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How do I use mixin types?

reply Andrej <a b.c> writes:
The D spec mentions something called mixin types:


If I'm understanding the grammar right, it means you can use a 
string mixin anywhere a Type would normally go, for example:

int func(mixin("int") x)
     return x;

However, when I try to compile that fragment (using dmd 2.086.1), 
it fails with the following error:

.\mixintype.d(1): Error: basic type expected, not `mixin`

...and then a few more cascading errors as a result of it not 
understanding the mixin.

I've tried placing the mixin on the right hand side of an alias 
declaration, but that didn't work either.

I've found literally nothing about this feature online except for 
the official spec so I'm starting to question whether this is an 
actual language feature or not...

I'd really like it to exist, otherwise I'd need to use a regular 
mixin declaration to define the entire function.
Aug 02 2019
parent Adam D. Ruppe <destructionator gmail.com> writes:
On Friday, 2 August 2019 at 21:10:08 UTC, Andrej wrote:
 The D spec mentions something called mixin types:
This is brand new to the spec and hasn't yet been released in a compiler. You can get a nightly build here https://dlang.org/changelog/pending.html to maybe try, but I don't think it will be in a proper release until ... my guess is Sept 1.
Aug 02 2019