[Issue 12597] Payload getter for std.typecons.Typedef

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Apr 22 14:38:43 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12597

--- Comment #7 from bearophile_hugs at eml.cc ---
(In reply to Andrej Mitrovic from comment #5)

> there are plenty of people on IRC that keep asking about it
> though, I typically don't recommend them to use Typedef since it's full of
> bugs.

While not strictly necessary, something like typedef/Typedef is sometimes
useful. In Haskell there's a built-in way to do it, using "newtype", and the
GHC compiler has one or more non-standard extensions
(GeneralizedNewtypeDeriving) to improve the use of newtype.


(In reply to Andrej Mitrovic from comment #6)
> You seem to have filed https://issues.dlang.org/show_bug.cgi?id=11706
> before, maybe we should just implement that instead? Then the cast would be
> safe.

The need to find the underlying type and the underlying value are both present.
So I think we need both enhancements. (I have also just added a note to Issue
11706 ). If you want to implement only one of the two, then I suggest to
implement a way to get the underlying value, because then getting the type is
one typedef away.

--


More information about the Digitalmars-d-bugs mailing list