Another problem with properties

BCS ao at pathlink.com
Fri Aug 24 07:22:45 PDT 2007


Reply to Aarti_pl,

> Below examples doesn't compile, but IMHO they should. Especially when
> properties are threated as functions like in D...
> 
> //--------------------
> //Example A
> //You can not make sure that every class will have some property
> interface I {
> int prop;
> }
> class Test : I {
> int prop;
> }
> //--------------------
> //Example B
> //When you define property as functions you have to use them in every
> //derived class
> interface I {
> int  prop();
> void prop(int);
> }
> class Test : I {
> int prop;
> }
> //--------------------
> //Example C
> //You can not extend property in derived function
> interface I {
> int  prop;
> }
> class Test : I {
> int prop();
> void prop(int);
> }
> //--------------------
> 
> Above examples *should* work. Current behavior reduces properties
> usefulness.
> 
> BR
> Marcin Kuszczak
> (Aarti_pl)


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.





More information about the Digitalmars-d mailing list