Another problem with properties

BCS ao at pathlink.com
Sat Aug 25 20:53:02 PDT 2007


Reply to Marcin,

> BCS wrote:
> 
>> Short version, proprtties are just function. Interfaces are just
>> functions.
>> 
>> That said, It wouldn't be impossible to have interfaces define
>> members (the vtable entry for them would be a pointer offset to get
>> from the interface instance to the member) but then there would be no
>> way to enforce encapsulation.
>> 
> What do you mean by "enforce encapsulation"? What would your
> proposition solve and what not?
> 

The idea (I'm not proposing it because I don't really like the idea) would 
let an interface have a member that is just data, not a function, however 
there would be no way to prevent code using it from doing arbitrary manipulation. 
It would be a public field. Also each member of the interface would still 
need to be done using a function or a field, but the interface definition 
would pick one not the interface implementation.


interface I { int i; }

class C1 : I { int i; } // works

class C2 : I { int i(){} } // doesn't work even though C2.i does





More information about the Digitalmars-d mailing list