Why there are no 'physical' object variables (only references)?

BCS BCS at pathlink.com
Tue Sep 12 08:33:51 PDT 2006


Lionello Lunesu wrote:
> BCS wrote:
> 
>> Sean Kelly wrote:
>>
>>> Kristian wrote:
>>>
>>>>
>>>> Hmm, what if structures could have interfaces and 
>>>> constructors/destructors... and what the heck, inheritance too? 
>>>> Hehheh, this way we would have 'physical classes' for local use and 
>>>> 'reference classes' for global use.
>>>
>>>
>>>
>>> It will never happen :-)  Though ctor support would be nice, at the 
>>> very least.  That would simplify initialization and eliminate the 
>>> need for the static opCall trick.
>>>
>>>
>>> Sean
>>
>>
>> There is no technical reason struct (or anything that can produce a 
>> delegate) can't do interfaces. Inheritance on the other hand... I hope 
>> that never happens.
> 
> 
> Wouldn't it add a hidden __vtbl to your struct and thereby increasing 
> its size?
> 
> L.
No, because the type of a struct is always known, the required value for 
the interface's function table can be found at compile time and all that 
is needed is to attach it to a reference to the struct.



More information about the Digitalmars-d mailing list