article comparing Rust and Zig, many points relevant to D
mw
mingwu at gmail.com
Wed Mar 10 21:49:12 UTC 2021
On Wednesday, 10 March 2021 at 18:08:24 UTC, H. S. Teoh wrote:
> 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;
>
If there is no optional identifier x2,
a.x = 2;
will change which x? and how to disambiguate the two x in such
case?
More information about the Digitalmars-d
mailing list