Is this a new bug ?
Newbie2019
newbie2019 at gmail.com
Sat Jul 20 04:10:53 UTC 2019
On Saturday, 20 July 2019 at 03:58:36 UTC, Adam D. Ruppe wrote:
> You should never actually need that! What is your use case?
>
> In most cases I see people doing .stringof, the correct
> solution is to simply... not. Use the local name directly.
>
> If you do need the name - and the only cases for this ought to
> be declaring a new item for public consumption or for
> interfacing with users - the correct way to get an identifier
> is `__traits(identifier, T)`... but again, more often than not,
> you do NOT need this and it is wrong to try!
>
> .stringof should almost never be used except for debugging, and
> string concatenation in string mixings is actually only
> necessary for new declaration names.
>
> OK:
>
> mixin("int " ~ name ~ " = T;");
>
> Wrong:
>
> mixin("int " ~ name ~ " = " ~ T.stringof ~ ";");
Thanks very much, __traits(identifier, Fn) is what I need.
I may not fully understand why I can done it without
identifier.stringof, I also need this string mixin for code and
debug. so I just go with __traits(identifier, Fn) right now.
More information about the Digitalmars-d-learn
mailing list