Final makes no difference?

BCS BCS at pathlink.com
Thu Aug 24 11:37:56 PDT 2006


Sean Kelly wrote:
> BCS wrote:
> 
>>
>> That brings up another bone of mine. why can't struct implement an 
>> interface? For that matter why not a function?
> 
> 
> Structs don't support inheritance, which is arguably required for 
> interface support.
> 
> 
> Sean

I don't see any technical problems for such a feature.

 From one perspective an instance of an interface is a multi-functioned 
delegate.

e.i.

delegate = {context*, function*}

vs.

interface = {context*, (function*)[]}

the function array is constructed per-class, per-interface and the two 
are tacked together at assignment.

Why then, couldn't a analogous array of function ptrs be gathered for a 
struct and used as an interface? It would be easier than with a class 
because the correct array of function can be found at compile time (vs. 
runtime for a class).

The same argument could hold for any context that a delegate can use, 
specifically nested function.



That said, I woudn't dream of this befor 2.0



More information about the Digitalmars-d-bugs mailing list