www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Redundancy of DRuntime and Phobos

reply Q. Schroll <qs.il.paperinik gmail.com> writes:
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`, 
`hasElaborate`*`Whatever`* that use a public import, but for 
whatever reason, they encapsulate the import and make an 
unnecessary template instance. None simply do
```D
public import core.internal.traits : Unconst;
```
but follow the pattern
```D
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
next sibling parent Paul Backus <snarwin gmail.com> writes:
On Friday, 21 May 2021 at 16:15:57 UTC, Q. Schroll wrote:
 Another example is `Unconst`, `Unqual`, 
 `hasElaborate`*`Whatever`* that use a public import, but for 
 whatever reason, they encapsulate the import and make an 
 unnecessary template instance. None simply do
 ```D
 public import core.internal.traits : Unconst;
 ```
 but follow the pattern
 ```D
 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
prev sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
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.
May 21 2021