Another use case for __traits(docComment)
schveiguy at gmail.com
Mon Nov 11 17:16:20 UTC 2019
On 11/8/19 9:00 AM, Adam D. Ruppe wrote:
> Writing code to wrap some Phobos functions for a script language and
> need documentation to be displayed at runtime...
> Would be really nice to just say if(other_docs.length == 0) return
> __traits(docComment, item).
> A UDA can populate other_docs in some functions, but when wrapping
> libraries you can't add that. Having the doc comment available through
> reflection means we can reuse these existing items.
I still am very VERY leery of having anything in comments affect the
code in any way.
What about a compromise? Provide access to the docs but ONLY at runtime.
That is, you will not know anything about the string at compiletime,
just at runtime, and you can make your decisions there.
Should work for your use case.
More information about the Digitalmars-d