detect implicitly convertible typeid's?

Steven Schveighoffer schveiguy at yahoo.com
Tue Sep 26 17:27:02 UTC 2017


On 9/26/17 12:56 PM, bitwise wrote:
> On Monday, 25 September 2017 at 15:12:57 UTC, Steven Schveighoffer wrote:
>> The answer to the last is that, yes, at the moment you need a custom 
>> runtime.
> 
> I really don't want to maintain a custom runtime just for this. It would 
> be nice if there was a compiler flag to specify an RTInfo template to 
> use. Or better yet, an attribute.
> 
> so this:
> 
> `
> module source;
> template MyRTInfo(T) { ... }
> `
> dmd source.d -rtinfo "source.MyRTInfo"
> 
> 
> Or even better, this:
> 
> `
> module reflection;
> @rtinfo template RTInfo(T) { ... }
> 
> module test;
> class Test{} // typeid(Test).rtinfo == reflection.RTInfo
> `
> dmd reflection.d test.d

I think there have been attempts to make the resulting rtinfo a 
combination of what druntime wants + whatever the type wants. But I'm 
not sure how far those got or the problems involved. I would expect that 
at some point we will need to flesh it out. It's more of an abstract 
concept than something anyone has used for meaningful work.

> So of course, dmd could complain if you specified more than one RTInfo 
> either way. If two static libraries were built with different RTInfo's, 
> I don't think it would technically be a problem since every TypeInfo 
> would get it's own rtinfo pointer anyways. Maybe something in the 
> runtime could somehow warn about mismatched RTInfo types like it does 
> about cyclic module dependencies.

I would expect that you could embed as many descriptors as you want 
inside the TypeInfo. We just have to come up with a way to store them in 
ROM and address them sensibly. Similar to a vtable.

-Steve


More information about the Digitalmars-d-learn mailing list