Library Typedefs are fundamentally broken
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Tue Sep 23 09:41:56 PDT 2014
On 9/23/14, 9:37 AM, H. S. Teoh via Digitalmars-d wrote:
> 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!
If language progress has gotten to the point where Typedef is obsolete
(I recall there were a bunch of issues with alias this at the time we
introduced Typedef), so much the better. I'm totally fine with "Typedef
is obsolete". It's the poetic injustice of "Typedef is broken/unusable"
I have a problem with. -- Andrei
More information about the Digitalmars-d
mailing list