Compiler patch for runtime reflection

Robert Jacques sandford at jhu.edu
Sat Oct 22 13:22:25 PDT 2011


On Sat, 22 Oct 2011 06:51:00 -0400, Alex Rønne Petersen <xtzgzorex at gmail.com> wrote:
> On 22-10-2011 05:36, Robert Jacques wrote:
>> On Fri, 21 Oct 2011 17:15:02 -0400, Alex Rønne Petersen
>> <xtzgzorex at gmail.com> wrote:
>>
>>> On 21-10-2011 21:07, Vladimir Panteleev wrote:
>>>> Hi,
>>>>
>>>> Igor Stepanov has created a patch for DMD and Druntime which adds RTTI
>>>> information for class and struct members.
>>>>
>>>> Example:
>>>>
>>>> import std.stdio;
>>>>
>>>> class Foo
>>>> {
>>>> static void PrintHello()
>>>> {
>>>> writeln("Hello");
>>>> }
>>>> }
>>>> void main()
>>>> {
>>>> auto info = cast(OffsetTypeInfo_StaticMethod)Foo.classinfo.m_offTi[0];
>>>> assert(info.name == "PrintHello");
>>>> auto print = cast(void function())info.pointer;
>>>> print(); //prints "Hello"
>>>> }
>>>
>>> Absolutely awesome!
>>>
>>>>
>>>> While the inclusion of such functionality into the language remains a
>>>> disputed matter, would anyone be interested in an unofficial patch for
>>>> this?
>>>
>>> Yes, very much. I would recommend setting up a fork on GitHub, and then
>>> adding it to a branch, e.g. 'reflection', if it's not going to be
>>> included in mainline DMD.
>>
>> Really? A runtime reflection system has been on the review queue for
>> over six months and I've brought the subject up on the newsgroup. I've
>> received zero feedback. So while I'm sure everyone want to check RTTI
>> off the D features list, I've not seen much real interest in it.
>
> I must have missed that. What should I search for to find your thread?

Don't bother; As I said, the thread went nowhere. However, if you'd like to look at the code / docs for my proposed improved variant module:

https://jshare.johnshopkins.edu/rjacque2/public_html/variant.mht
https://jshare.johnshopkins.edu/rjacque2/public_html/variant.d


More information about the Digitalmars-d mailing list