Library Typedefs are fundamentally broken

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 23 09:37:06 PDT 2014


On Tue, Sep 23, 2014 at 09:26:51AM -0700, Andrei Alexandrescu via Digitalmars-d wrote:
> On 9/23/14, 9:15 AM, Adam D. Ruppe wrote:
> >On Tuesday, 23 September 2014 at 16:01:35 UTC, Andrei Alexandrescu wrote:
> >>mixin(makeTypedef!("HMENU", void*));
> >
> >struct HMENU { void* _; alias _ this; }
> >
> >Don't even have to import a Phobos module for it!
> 
> Even better. I love good idioms! -- Andrei

To me, this is a big reason for Typedef being of little use. It's just
so easy to use struct + alias this to achieve what you want (and to do
so without tricky issues or hacks like counters or whatnot, plus you get
to control exactly how it should behave without bothering with template
parameters -- you can even do things like overload operators / methods,
that Typedef can't do), that I find myself wondering what Typedef is
actually good for, if anything!


T

-- 
Talk is cheap. Whining is actually free. -- Lars Wirzenius


More information about the Digitalmars-d mailing list