On 09/23/2014 06:01 PM, Andrei Alexandrescu wrote:

alias HMENU = Typedef!(void*, __MODULE__ ~ ".HMENU");
alias HFONT = Typedef!(void*, __MODULE__ ~ ".HMENU"); // oops

mixin(makeTypedef!("HMENU", void*));
mixin(makeTypedef!("HFONT", void*));

I said and I repeat: I do agree it's less convenient than a baked-in
facility. Even with the proper default arguments and all. ...


But at that point, why not mix in an entire struct declaration?
We even get better error messages out of this:

module a.b.c;
mixin MakeTypedef!("HMENU",void*));
mixin(makeTypedef!("HFONT",void*));

void main(){
    HMENU hm;
    HFONT hf;
    hf=hm;
}

The error message will mention types 'HMENU' and 'Typedef!(void*,"a.b.c.HFONT")'.

Furthermore, types will be distinct because the module system understands that they are distinct declarations.

Reply via email to