Re: Unqualified class name

2021-08-21 Thread jfondren via Digitalmars-d-learn
On Sunday, 22 August 2021 at 00:18:18 UTC, Ali Çehreli wrote: I did not read the linked thread but a "this template parameter" seems to work in this case: class Whoami { string name(this This)() const { return __traits(identifier, This); } } class AnotherOne : Whoami { } unittest {

Re: Unqualified class name

2021-08-21 Thread Ali Çehreli via Digitalmars-d-learn
On 8/21/21 2:48 PM, jfondren wrote: On Saturday, 21 August 2021 at 21:13:58 UTC, Jeremy T. Gibson wrote: On Saturday, 21 August 2021 at 18:27:34 UTC, Ali Çehreli wrote:     return __traits(identifier, typeof(this)); That works perfectly!  Thanks. =) This is exactly the solution you linked

Re: Unqualified class name

2021-08-21 Thread jfondren via Digitalmars-d-learn
On Saturday, 21 August 2021 at 21:13:58 UTC, Jeremy T. Gibson wrote: On Saturday, 21 August 2021 at 18:27:34 UTC, Ali Çehreli wrote: return __traits(identifier, typeof(this)); That works perfectly! Thanks. =) This is exactly the solution you linked to in your first post, and found

Re: Unqualified class name

2021-08-21 Thread Jeremy T. Gibson via Digitalmars-d-learn
On Saturday, 21 August 2021 at 18:45:07 UTC, jfondren wrote: On Saturday, 21 August 2021 at 17:33:51 UTC, Jeremy T. Gibson wrote: is there a simple way to get the unqualified name of a class at runtime without having to pass it through std.format? `typeid(class).name` always yields the full

Re: Unqualified class name

2021-08-21 Thread Jeremy T. Gibson via Digitalmars-d-learn
On Saturday, 21 August 2021 at 18:27:34 UTC, Ali Çehreli wrote: return __traits(identifier, typeof(this)); That works perfectly! Thanks. =)

Re: Unqualified class name

2021-08-21 Thread jfondren via Digitalmars-d-learn
On Saturday, 21 August 2021 at 17:33:51 UTC, Jeremy T. Gibson wrote: is there a simple way to get the unqualified name of a class at runtime without having to pass it through std.format? `typeid(class).name` always yields the full classname, including its module information (i.e.,

Re: Unqualified class name

2021-08-21 Thread Ali Çehreli via Digitalmars-d-learn
On 8/21/21 10:33 AM, Jeremy T. Gibson wrote: `typeid(class).name` always yields the full classname, including its module information (i.e., "modulename.classname"), where I only want "classname" on its own. I've been reminded of __traits(identifier) on this forum just yesterday: import

Unqualified class name

2021-08-21 Thread Jeremy T. Gibson via Digitalmars-d-learn
I saw this thread -- https://forum.dlang.org/post/hdkvezicxfvehbtvj...@forum.dlang.org -- which works at compile time (although templating seems like overkill for my purpose), but is there a simple way to get the unqualified name of a class at runtime without having to pass it through