What's the deal with the massive duplication in std.meta?

Steven Schveighoffer schveiguy at gmail.com
Sat May 1 15:50:28 UTC 2021


On 4/30/21 6:03 PM, Andrei Alexandrescu wrote:

> It all starts simple, like a toddler babble:
> 
> ```D
> alias Alias(alias a) = a;
> alias Alias(T) = T;
> ```

> 
> The reader (including seasoned maintainer) would go like, "What? Why 
> does it need to be defined twice? Wouldn't a type also fit an alias?" 
> And indeed if said maintainer comments out the second declaration, a 
> couple of obscure errors show up in unittesting (mind you, not 
> unittesting of std.meta, but of completely unrelated modules).

I'm going to take a guess that this is because older compilers would not 
accept keywords as alias parameters (so e.g. Alias!int would not work 
without the T overload). There are likely leftover workarounds, either 
of this type, or of the form of:

```d
template Alias(T...) if (T.length == 1)
{
    alias Alias = T[0];
}
```

I think if we can get rid of all of the overloads/workarounds, we should.

-Steve


More information about the Digitalmars-d mailing list