Non-fragile ABI in D?

Walter Bright newshound1 at digitalmars.com
Sun Feb 8 02:41:11 PST 2009


Michel Fortin wrote:
> There are many options. Either it's done by the linker and the dynamic 
> library loader, or it's done by the library initialization code, or 
> lazily on the first use of a class. Or we don't use virtual function 
> tables at all...

As one wag put it, the solution to all problems is another level of 
indirection. This can work here, too. Have your only field in a class be 
a reference to an opaque type, and a member function that is a 
dispatcher based on a string argument or such.

The implementation of the member function dispatches to the actual class 
being opaquely referenced and the string value. This is all completely 
hidden from the user, so it can be arbitrarily extended without the user 
needing to recompile.

In dynamic languages, this is what happens anyway under the hood. It's 
how javascript works, for example.

The downside is it's quite a bit slower.



More information about the Digitalmars-d mailing list