"External interfaces" or "Interface maps"

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Oct 17 18:28:48 PDT 2008


Hxal wrote:
> =========================== External interfaces ===============================
> 
> The idea is to allow implementing an interface for a class, outside the
> class' definition. This is possible as I understand, because interfaces are
> "fat" pointers -- they consist of an object reference and the interfaces'
> vtable for the particular class, which is separate from the class' vtable.
> Therefore it should be possible to create an interface vtable outside
> the module that declares the class.
[snip]

It's a nice idea. I asked Walter about it today. Interfaces are not fat 
pointers, but your scheme could be implemented in other ways (in essence 
allocating vtables dynamically). This would be a sizeable implementation 
effort. The question is, to what extent would post-factum interfaces 
enable or improve idioms?

Also, it might be of interest to you that I implemented compound types 
as described by Buchi and Weng, see 
https://eprints.kfupm.edu.sa/31204/1/31204.pdf), and also straight 
structural casts. These should cover at least a few idioms that could 
use post-factum interfaces. I haven't released the code to public 
attention because I haven't gotten around to it.


Andrei




More information about the Digitalmars-d mailing list