article comparing Rust and Zig, many points relevant to D

jmh530 john.michael.hall at gmail.com
Wed Mar 10 18:17:19 UTC 2021


On Wednesday, 10 March 2021 at 17:59:56 UTC, VF wrote:
> [snip]
>
> I think the biggest reasons are bugginess and instability. 
> Those are my reasons for wanting to get out of D, and also 
> feature bloat. I want a simpler language, but am not seeing 
> good options...
>
> 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!
>
> int main() {
>     import std.stdio;
>     writeln(A.sizeof);       // => 8
>     writeln(A.id.offsetof);  // => 4
> }

I couldn't get this exact thing to run (the A.id.offsetof part 
and using int main instead of void main), but in general if you 
come across a bug you should file it in bugzilla.

You need to be specific about what you think the bug actually is. 
According to the spec
https://dlang.org/spec/template-mixin.html#mixin_scope
there is no reason why this shouldn't compile as int x overrides 
the mixin.

A reasonable question might be "if int x overrides what is in X, 
then why is it still a part of A"? There might be good reasons 
for why A.sizeof is 8 instead of 4.


More information about the Digitalmars-d mailing list