Help in reviewing druntime PR
Paul Backus
snarwin at gmail.com
Thu Dec 9 15:06:24 UTC 2021
On Thursday, 9 December 2021 at 09:47:10 UTC, Stanislav Blinov
wrote:
> ...I mean, it looks like this would have to be ported into
> Phobos as well, seeing as there's still this weird code
> duplication for those symbols going on. Though I would rather
> see those things removed from Phobos and aliased into core,
> deprecated, then deleted for good.
>
> But I could add the Phobos change too if there's more eyes
> there.
Something like this is already in Phobos, under the name
[`std.traits.hasNested`][1].
However, the behavior is not exactly the same. The Phobos version
recurses into classes, even though they are reference types,
leading to results like the following:
```d
void example()
{
import std.traits;
class Nested {}
static struct NotNested
{
Nested nested;
}
pragma(msg, hasNested!NotNested); // true
}
```
I'm not really sure what we should do about this. The Phobos
behavior seems obviously incorrect to me, but "fixing" it is a
potentially-breaking change. Maybe the right thing to do is to
add the fixed version to Phobos as
`std.traits.hasContextPointers` and mark `hasNested` as
outdated/unrecommended in the documentation. Thoughts?
[1]: https://dlang.org/phobos/std_traits.html#hasNested
More information about the Digitalmars-d
mailing list