UDP enhancement

Ali Çehreli acehreli at yahoo.com
Sun Jun 30 19:17:24 PDT 2013


On 06/30/2013 06:43 PM, JS wrote:

 >> On Monday, July 01, 2013 03:22:15 JS wrote:
 >>> struct Foo
 >>> {
 >>>      @property int data() { return m_data; } // read property
 >>>      @property int data(int value) { return m_data = value; } //
 >>> write property
 >>>      private: int m_data;
 >>> }
 >>>
 >>> It would be nice if properties had an internal variable to use
 >>> instead of having to declare it explicitly:
 >>>
 >>>
 >>> struct Foo
 >>> {
 >>>      @property int data() { return data.value; } // read property
 >>>      @property int data(int value) { return data.value; } // write
 >>> property
 >>> }
 >>>
 >>> This reduces code complexity.

I have the complete opposite view: Seeing what m_data explicitly in the 
code would be simpler than reading code to see that data.value would 
mean implicit storage.

 > (if propertyname.value is used then
 > there needs to be an internal variable, else not),

Where would the compiler make room for that variable in relation to the 
other members? With programming languages, explicit is almost always 
better than implicit.

Ali



More information about the Digitalmars-d mailing list