What is Tdummy doing in (may|does)PointTo?
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Thu Apr 14 11:56:19 PDT 2016
On 04/14/2016 02:50 PM, Vladimir Panteleev wrote:
> On Thursday, 14 April 2016 at 18:47:41 UTC, Andrei Alexandrescu wrote:
>> https://dlang.org/library/std/exception/may_point_to.html
>> https://dlang.org/library/std/exception/does_point_to.html
>>
>> We have an unfortunate pattern in Phobos: things that start out as
>> simple ideas with nice implementations (in this case pointsTo) slowly
>> change into complicated artifacts with undocumented rationale. We
>> really should rein in documentation, not only external but also
>> internal. In this case I cannot for the life of me figure what Tdummy
>> does, and the only appearance of the name is in the respective
>> definitions.
>
> Generally, if you don't understand why something is there, you could...
>
> 1. git blame
I know, but my point is that shouldn't be the way. Rationale for why
something is there should be in there, not in the accumulated history of
commit explanations.
> 2. Delete it and see which tests fail :)
>
> In this case it appears to be used to disambiguate between the
> overloaded template.
Thanks. That's the shared overload. Isn't there a much better solution?
Why isn't shared handled inside the body along with the other cases?
Also, why is this:
foreach (i, Subobj; typeof(source.tupleof))
if (mayPointTo(source.tupleof[i], target)) return true;
not written easier like this:
foreach (ref member; source.tupleof)
if (mayPointTo(member, target)) return true;
?
Andrei
More information about the Digitalmars-d
mailing list