another cool RTInfo trick - i want in runtime

Vladimir Panteleev vladimir at thecybershadow.net
Thu Jan 16 10:15:38 PST 2014


On Thursday, 16 January 2014 at 15:57:05 UTC, Adam D. Ruppe wrote:
> Check this out. Modify your druntime slightly. In object.di, 
> find template RTInfo(T) and add this bit:

Suggestions:

1. I guess TypeCheck is a temporary name? I would suggest e.g. 
CustomRTInfo.

2. How about using a template mixin instead of a template? Then 
you can drop the dummy bool. I know that if you use a mixin, you 
can't refer to stuff that's in the scope where it's declared, but 
I think that's OK - because you probably don't want an object 
file for config.d anyway, since:

3. rdmd will not add config.d to the compiler's command line, 
since it lies in an excluded package "core" (so it's assumed 
it'll be in phobos.lib). But that's OK, since there will be no 
symbols in config.d to link against anyway!

It all fits together quite nicely. You can access stuff in your 
main program by importing its modules within the template mixin.


More information about the Digitalmars-d mailing list