Another problem with properties

Marcin Kuszczak aarti at interia.pl
Fri Aug 24 14:32:51 PDT 2007


Daniel Keep wrote:

> As I said, I'm not sure what your argument is.  You seem like you want
> to add fields to an interface which is utterly impossible due to the way
> interfaces work.  Virtual functions are stored in offsets in the vtable,
> whilst fields are stored as an offset from the start of the class' chunk
> of allocated memory.  I don't know of any language that has properties
> and interfaces that lets you put regular fields into an interface.
> 
> That said, I've put properties in interfaces lots of times, and I've
> never really seen a problem with it.
> 
> -- Daniel

My main intent was to point out that current D properties implementation is
not serving its purpose of hiding differences between fields and methods
very well. There are cases in which current properties just doesn't work.
Please notice that when you don't need setters and getters in specific
derived class defining two silly methods is rather inconvenient. I was not
trying to find solution, but just define another problem with them.

In Java you can put fields in interface, but it doesn't make it necessary to
implement field in derived classes/interfaces. Probably because Java
interfaces are implemented as abstract classes in D. IMHO such a behaviour
is not proper as interfaces should constrain implementation.

-- 
Regards
Marcin Kuszczak (Aarti_pl)
-------------------------------------
Ask me why I believe in Jesus - http://zapytaj.dlajezusa.pl (en/pl)
Doost (port of few Boost libraries) - http://www.dsource.org/projects/doost/
-------------------------------------




More information about the Digitalmars-d mailing list