Structs implementing interfaces in D1

BCS none at anon.com
Tue Feb 10 15:48:24 PST 2009


Hello Tom,

> Tim M wrote:
> 
>> Is there a reason to have structs instead of classes/objects to do
>> whatever you use them for or is that besides the point?
>> 
> Structs are more lightweight because they don't carry the 'monitor'
> and vtable pointer. It's also easier to create them on the stack e.g.
> in arrays. But my code was mostly a proof of concept implementation,
> since many folks did not realize that structs might implement
> interfaces too. It would also be possible to do more exotic stuff,
> like constructing interface 'instances' out of free functions at
> runtime. My point was to show one possible way.
> 

I have long thought that you should be able to generate an interface out 
of nested functions.

All of this would be trivial if COM interop could be dumped and interfaces 
done as a context/vtbl pairs.





More information about the Digitalmars-d mailing list