How do I use mixin types?

Andrej a at b.c
Fri Aug 2 21:10:08 UTC 2019


The D spec mentions something called mixin types:

https://dlang.org/spec/grammar.html#MixinType
https://dlang.org/spec/type.html#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.


More information about the Digitalmars-d-learn mailing list