Another use case for __traits(docComment)

Dennis dkorpel at gmail.com
Wed Nov 13 20:38:07 UTC 2019


On Wednesday, 13 November 2019 at 19:44:38 UTC, Adam D. Ruppe 
wrote:
> The ONLY addition I am calling for is that a trait docComment 
> (or whatever) returns the ddoc string attached to the 
> declaration

That may be the only thing _you_ want, but then someone else 
comes along who wants something different.
All Manu wanted was a mangle-only `extern(C++, "ns")` as an 
additional option, so simple. Why was Walter initially so 
resistant for such a harmless addition? Then it got merged.

https://github.com/dlang/dmd/pull/8667

Then the issues come in.

https://issues.dlang.org/show_bug.cgi?id=19278
https://issues.dlang.org/show_bug.cgi?id=19339
https://issues.dlang.org/show_bug.cgi?id=19557
https://issues.dlang.org/show_bug.cgi?id=19574
https://issues.dlang.org/show_bug.cgi?id=19893
https://issues.dlang.org/show_bug.cgi?id=19920

And someone wants to deprecate the old way.

https://github.com/dlang/dmd/pull/10031

I'm not saying it wasn't worth it in that case, but those 
fictional remarks about __traits(docComment) were supposed to 
show that the trait will be ANOTHER source of enhancement 
requests, introduces ANOTHER thing that can get queried during 
any point of semantic analysis, probably making it ANOTHER source 
of DMD bugs, and it will be ANOTHER source of confusion / 
material for D learners to swallow.

That's just how it goes despite how simple it may look, and the 
question is whether the new trait justifies this cost. Not every 
code annoyance warrants a new feature, sometimes it's better to 
e.g. duplicate a few lines of code instead of introducing another 
C-macro.

Likewise, in this case having some duplication in UDA's or having 
another build step may be the easier solution in the end.


More information about the Digitalmars-d mailing list