On Thursday, 22 July 2021 at 18:16:54 UTC, Tejas wrote:
On Thursday, 22 July 2021 at 18:06:07 UTC, Paul Backus wrote:
On Thursday, 22 July 2021 at 17:38:09 UTC, Tejas wrote:
Why does this work?
```d
import std;
void main()
{
mixin("int") a;
writeln(a);
}
```
You can mix in a type:
https://dlang.org/spec/type.html#mixin_types
Looks like special casing to me... is it allowed because they
are guaranteed to not introduce a scope, I wonder.
The list of things you're allowed to mix in is:
* expressions
* statements
* declarations
* types
In some sense it is special casing, since there's no overarching
rule that determines what goes on that list and what doesn't.