Library Typedefs are fundamentally broken
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 22 17:30:09 PDT 2014
On Tue, Sep 23, 2014 at 12:13:19AM +0000, Adam D. Ruppe via Digitalmars-d wrote:
> On Tuesday, 23 September 2014 at 00:01:51 UTC, Shammah Chancellor wrote:
> >What exactly was wrong with the original typedef statement that was
> >deprecated?
>
> I personally find it too inflexible; it virtually never does exactly
> what I need. BTW I've never used std.typecons.Typedef for the same
> reason.
>
> But what are some examples of typedef? HANDLE and HMENU are close to
> useful indeed, I've used typedef for that kind of thing before. But it
> isn't perfect: do you ever want do do *handle? That's allowed with
> typedef. Do you want it to explicitly cast to void*? That's allowed
> with typedef.
>
> People couldn't agree on if typedef should be a subtype or a separate
> type either, which fed the deprecation. Personally though I think
> that's silly, if what it does is well defined, we can keep it and do
> other things for the other cases. But it does need to be compelling
> over another feature to be kept and I'm not sure it is.
>
> So I tend to prefer struct and a little alias this and disabled
> overloads to a typedef. A wee bit more verbose, but more flexible and
> correct too.
Yeah, I think struct + alias this + function/operator overloading pretty
much does whatever typedef may have done, except better. So I personally
don't miss typedef at all (not Typedef, for that matter).
T
--
Freedom: (n.) Man's self-given right to be enslaved by his own depravity.
More information about the Digitalmars-d
mailing list