compiler support added for precise GC

Robert Clipsham robert at octarineparrot.com
Wed Apr 18 03:07:59 PDT 2012


On 18/04/2012 02:11, Nick Sabalausky wrote:
> Can't you just query compile-time information to see what classes inherit
> from Base? Then you could just try downcasting to them.

Last time I checked there was no way to do that (I doubt that will have 
changed). It's impossible to know all the subclasses until link-time, so 
you'll get different results depending on how you compile your project. 
The only way around this that I've found is to put a mixin in all 
subclasses to register them with the base class... That's a complete 
hack though.

Example:
----
// a.d
class Base { /* whatever magic to get derived classes */ }
// b.d
import a;
class Derived : Base {}
void main() {}
----
$ dmd -c a.d

dmd does not know about b.d when compiling a.d. The only way this could 
work is to allow link-time code generation.

-- 
Robert
http://octarineparrot.com/


More information about the Digitalmars-d mailing list