article comparing Rust and Zig, many points relevant to D

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Mar 10 18:08:24 UTC 2021


On Wed, Mar 10, 2021 at 05:59:56PM +0000, VF via Digitalmars-d wrote:
[...]
> Speaking of bugginess, here's the latest bug that I noticed (dmd 2.094):
> 
> mixin template X() { int x; }
> 
> struct A { mixin X; int x; } // <- that compiles!

This is not a bug. It's a feature. (Although its value is debatable.)
Mixins exist in separate namespaces, which can be useful if you have
multiple mixins that declare the same identifier. Note that there's an
optional identifier after `mixin X` that can be used to disambiguate
between the two instances of `x`, e.g.:

	struct A {
		mixin X x2;
		int x;
	}

	A.x2.x = 1;
	a.x = 2;


T

-- 
In a world without fences, who needs Windows and Gates? -- Christian Surchi


More information about the Digitalmars-d mailing list