@property

Jacob Carlborg doob at me.com
Sat Aug 4 12:11:47 PDT 2012


On 2012-08-04 21:08, Jacob Carlborg wrote:

> I think that you should always be able to replace a variable with a
> property. The other way around I'm not so sure. The problem is with
> methods in classes. Since a method will be virtual by default you can't
> just replace a property with a variable. That could potentially break
> subclasses that override the property.

I wouldn't actually mind a way to do this, perhaps something like this:

class Foo
{
     @property int bar:
}

Would be the same as:

class Foo
{
     private int bar_:
     @property int bar () { return bar_; }
     @property int bar (int value) { return bar_ = value; }
}

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list