UDP enhancement

JS js.mdnq at gmail.com
Sun Jun 30 18:22:15 PDT 2013


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. If a property does not use the 
internal variable(which I signify by .value) then it does not add 
any storage. This allows one to easily wrap fields into 
properties without having to create private fields for each 
property unless needed.


More information about the Digitalmars-d mailing list