www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: structs, classes, interfaces - Part III, Solution

 Internally a pointer to an interface would actually be a struct
 containing the vtable and a pointer to the object which would be a
 tiny bit more costly than a class reference.

I've wanted this for a LONG time. It would allow all sorts of fun things to implement an interface (functions, structs, maybe even basic types). Alas it would break COM or require a totally incompatible special case. (I darn to heck whoever defined the COM standard that way!)

This is the same as what I've been calling "typed pointers" in Cx: http://tinycx.sourceforge.net/typeptr.html. You can add methods to builtin types like "double" or "int". Cx is temporarily on the back burner so there are no downloads available but I hope to return to it soon. -Ben
Sep 05 2007