Library Typedefs are fundamentally broken
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Sun Sep 21 08:15:29 PDT 2014
On 9/21/14, 7:22 AM, Dicebot wrote:
> On Saturday, 20 September 2014 at 17:20:28 UTC, Andrei Alexandrescu wrote:
>> On 9/20/14, 9:32 AM, ketmar via Digitalmars-d wrote:
>>> On Sat, 20 Sep 2014 08:25:17 -0700
>>> Andrei Alexandrescu via Digitalmars-d <digitalmars-d at puremagic.com>
>>> wrote:
>>>
>>>> I think this is an entirely palatable idiom:
>>>> alias ALfloat = std.typecons.Typedef!(float, "ALfloat");
>>> this is ugly.
>>
>> But not unusable.
>
> Requiring manual tracing of identity = unusable. With my proposed
> implementation it is at least clear when it is going to fail. This is
> much worse:
>
> module a;
>
> alias Int1 = Typedef!(int, "MyInt");
alias Int1 = Typedef!(int, "a.Int1");
> module b;
>
> alias Int2 = Typedef!(int, "MyInt");
alias Int2 = Typedef!(int, "b.Int2");
> // oh I didn't know someone else used that cookie too..
> static assert (is(Int1 == Int2));
>
> Such solution simply can't be allowed in any project with >1 active
> programmer unless either type safety is not important or some additional
> restrictions on adding new typedefs are added process-wise (insane).
More hyperbole won't help the weakness of the argument.
Andrei
More information about the Digitalmars-d
mailing list