core.reflect vs c++ reflection

bauss jj_1337 at live.dk
Mon Sep 27 07:32:48 UTC 2021


On Monday, 27 September 2021 at 07:28:46 UTC, Stefan Koch wrote:
> On Monday, 27 September 2021 at 06:25:07 UTC, bauss wrote:
>> On Sunday, 26 September 2021 at 19:09:31 UTC, Stefan Koch 
>> wrote:
>>> On Sunday, 26 September 2021 at 19:03:24 UTC, Stefan Koch 
>>> wrote:
>>>> Good day,
>>>
>>>>
>>>>
>>>> Please let know what you think.
>>>
>>> Ugh typo.
>>>
>>>>static immutable ed = cast(EnumDeclaration)nodeFromName(E);
>>>
>>> is supposed to be:
>>>
>>> `static immutable ed = 
>>> cast(EnumDeclaration)nodeFromName("E");`
>>
>> What about E.stringof? Instead of hardcoding names :) Not sure 
>> if stringof will return E in all cases, so obviously only if 
>> it works.
>
> E stringof would return the name of the type;
> In simple cases and garbage in others.
>
> Whereas the name E always refers to the type used in the 
> toString template.
> Also "E" is less typing than E.stringof

Yeah I figured it wouldn't work that easily.

In this case yeah "E" wouldn't be a problem but if it was 
"ThisTypeName" you might end up with a typo.


More information about the Digitalmars-d mailing list