DIP4: Properties

Michiel Helvensteijn m.helvensteijn.remove at gmail.com
Sun Jul 26 14:45:22 PDT 2009


BLS wrote:

>> A one liner should do the trick too.
>> [public] [const] property int i;
> 
> I am a little bit ''' about the feedback :
> Is there really nobody who got it :

I think people got it. But it's not a property. Your one-liner seems to be
equivalent to a field. Except, I guess, that you can't take the address.

The whole idea of a property is that it can have non-trivial getter/setter
functions. Like a read-only property of a Line, that returns its length
automatically calculated from its two points. Or a getter and setter that
keep a log of all accesses to the information.

My favorite example is of a Color class, that internally stores its value in
the RGB model, but has properties to read and change its value through the
HSV and HSL models as well.

-- 
Michiel Helvensteijn




More information about the Digitalmars-d mailing list