Virtual methods

Walter Bright newshound1 at digitalmars.com
Wed Feb 3 19:04:43 PST 2010


bearophile wrote:
> Walter Bright:
>> That's not safe because there are always opaque modules that are
>> binary only. They may derive from the class in the module - and the
>> optimizer cannot prove they don't.
> 
> This sounds like: Lasciate ogni speranza, voi ch'entrate.
> 
> Let's try again. I think there can be two types of opaque binary only
> modules: - Ones compiled from C code, or with a C interface. Such
> modules can't contain classes, so there is no problem with virtual
> functions. - Ones compiled from D code, or that use the D code
> interface, that can contain and use classes and virtual calls. The
> language can require such modules to contain a data structure that
> tells the compiler what's safe to do.


A link step is required to figure out what modules wind up in the final 
program. So, in order for this to get the information into the front end 
where it belongs, you essentially need to compile it, link it, feed the 
results of the link back into the compiler, recompile, and relink.

Not impossible, and a "pseudo-link" could be done after the semantic 
phase of compilation, but these things would be a lot of work to implement.



More information about the Digitalmars-d mailing list