Thread overview
Redundancy of DRuntime and Phobos
May 21, 2021
Q. Schroll
May 21, 2021
Paul Backus
May 21, 2021
Adam D. Ruppe
May 21, 2021

I noticed that core.internal.traits contains a lot of stuff that is exactly the same in std.traits and std.meta. Is that for legacy reasons or should new additions be also redundant (and why)?

For example, there's redundant AliasSeq which I understand because it's kind of trivial and public-importing is on par with it. (I'd still prefer the import.)
Another example is Unconst, Unqual, hasElaborateWhatever that use a public import, but for whatever reason, they encapsulate the import and make an unnecessary template instance. None simply do

public import core.internal.traits : Unconst;

but follow the pattern

template Unconst(T)
{
    import core.internal.traits : CoreUnconst = Unconst;
    alias Unconst = CoreUnconst!(T);
}

I guess there's a good reason to do this and I'd like to understand.

In core.internal.traits there is a lot of stuff commented with "taken from". Why all this duplication? Are PRs to Phobos welcome that public-import the core stuff? Are PRs to DRuntime welcome that move improved stuff from Phobos to it (and replace the Phobos stuff by a public import)?

May 21, 2021

On Friday, 21 May 2021 at 16:15:57 UTC, Q. Schroll wrote:

>

Another example is Unconst, Unqual, hasElaborateWhatever that use a public import, but for whatever reason, they encapsulate the import and make an unnecessary template instance. None simply do

public import core.internal.traits : Unconst;

but follow the pattern

template Unconst(T)
{
    import core.internal.traits : CoreUnconst = Unconst;
    alias Unconst = CoreUnconst!(T);
}

I guess there's a good reason to do this and I'd like to understand.

Probably for the documentation. Public imports don't generate good ddoc output.

May 21, 2021

On Friday, 21 May 2021 at 16:15:57 UTC, Q. Schroll wrote:

>

I noticed that core.internal.traits contains a lot of stuff that is exactly the same in std.traits and std.meta. Is that for legacy reasons or should new additions be also redundant (and why)?

As I understand it, they were added to Phobos first, then people wanted them in druntime, but druntime cannot import phobos, so it copy/pasted, but then the duplication was annoying, so phobos then imported druntime.

I think it is more an accident of history and maybe some compatibility worries more than anything else.

Or indeed it could be doc related. adrdox handles public imports pretty ok but ddoc doesn't.