Why do we have uncommented and undocumented symbols in std.traits?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri May 7 20:58:25 UTC 2021


On 5/7/21 4:50 PM, Petar Kirov [ZombineDev] wrote:
> On Friday, 7 May 2021 at 16:31:35 UTC, Andrei Alexandrescu wrote:
>> BooleanTypeOf
>> IntegralTypeOf
>> FloatingPointTypeOf
>> NumericTypeOf
>> UnsignedTypeOf
>> SignedTypeOf
>> CharTypeOf
>> StaticArrayTypeOf
>> DynamicArrayTypeOf
>> ArrayTypeOf
>> AssocArrayTypeOf
>> BuiltinTypeOf
>>
>> Looking at their subtly repetitive definitions, they are specious to 
>> start with, but they have absolutely no comments so who knows what 
>> they're useful for.
>>
>> People ask "what would do phobos better?" and it's ironic because 
>> literally whatever file I open there are dozens of immediate and 
>> urgent improvements to be done that scream at you.
> 
> As far as I can tell from the [PR][0] that added them, they were needed 
> so that `std.format` can treat `struct S(T) { T x; alias x this; }` as 
> `T` if `T` is a built-in type, by having `AbcTypeOf!(S(T))` yield `T`, 
> if `T` is `Abc` (e.g. Boolean, FloatingPoint, etc.) in template 
> constraints.

Thanks.

Ah, our old friend "alias this" to be weirdly supported everywhere.

That code must be removed at once with maximum prejudice.

> In other words, it looks like they were meant only for Phobos-internal 
> use. These days, we use `package (std)` for such symbols. Perhaps that 
> `package` protection attributes were not implemented (or not working 
> reliably) in ~2012?
> 
> There is no discussion in that pull request, so perhaps you had 
> discussed the matter with Kenji either on the newsgroup, Bugzilla, in 
> other pull request, or privately?
> 
> [0]: https://github.com/dlang/phobos/pull/488

I made a terrible mistake accepting that PR.


More information about the Digitalmars-d mailing list