www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - What is RTInfo?

reply "Mike" <none none.com> writes:
object.d [1] says it's infomation for the precise GC (which I 
thought wasn't implemented yet).

It just seems to return a void*.  But, searching the source code, 
it doesn't seem to be set by anything anywhere.

So, what is RTInfo and what is its purpose.  And how is it 
different from TypeInfo?

Thanks,
Mike

[1] 
https://github.com/D-Programming-Language/druntime/blob/f0c1e13d8bd547eed517b1ae17f085966bb165c1/src/object.di#L180
Jan 29 2015
next sibling parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Thursday, 29 January 2015 at 08:47:18 UTC, Mike wrote:
 It just seems to return a void*.  But, searching the source 
 code, it doesn't seem to be set by anything anywhere.
It can actually return anything: RTInfo is a template that is automatically instantiated for each user-defined struct or class in a program. https://github.com/D-Programming-Language/druntime/blob/f0c1e13d8bd547eed517b1ae17f085966bb165c1/src/object.di#L682 It isn't actually doing anything yet in the lib, but it could if you wanted to modify druntime. IT can do anything - custom, user extensions to TypeInfo, building trees of types, or making maps of things for the GC (which is why it is there, just nobody has actually used it yet). It is one of the cool hidden gems there that is unutilized so far.
Jan 29 2015
prev sibling parent Steven Schveighoffer <schveiguy yahoo.com> writes:
On 1/29/15 3:47 AM, Mike wrote:
 object.d [1] says it's infomation for the precise GC (which I thought
 wasn't implemented yet).

 It just seems to return a void*.  But, searching the source code, it
 doesn't seem to be set by anything anywhere.

 So, what is RTInfo and what is its purpose.  And how is it different
 from TypeInfo?
For every TypeInfo generated by the compiler, it also instantiates the RTInfo(T) template [1] and puts the result into m_rtInfo. This allows anyone to generate anything they want at compile time and put it into the TypeInfo system. Could be Precise GC stuff, could be reflection stuff, anything you want. At the moment it's just a toy for tinkerers to try nifty things with :) There has been discussion as to how we can make the system extensible, so you don't have to build a new runtime to add things to TypeInfo. But nothing concrete so far has been added. It's just a hook from the compiler. -Steve [1] https://github.com/D-Programming-Language/druntime/blob/f0c1e13d8bd547eed517b1ae17f085966bb165c1/src/object.di#L682
Jan 29 2015