@property needed or not needed?

Jonathan M Davis jmdavisProg at gmx.com
Mon Jan 28 10:26:38 PST 2013


On Monday, January 28, 2013 13:31:34 Jacob Carlborg wrote:
> > Having the compiler lower the following:
> > 
> > @property int a;
> > 
> > to
> > 
> > private int __a;
> > 
> > @property int a() {
> > return __a;
> > }
> > @property int a(int new_a) {
> > 
> > __a=new_a;
> > return __a;
> > 
> > }
> 
> I would love that. But the setter should return void and the compiler
> should to property rewrites.

Both should work. It's more efficient to chain assignments if the setter returns 
a value, but chaining should still work if it returns void. It would just be 
lowered differently in that case.

- Jonathan M Davis


More information about the Digitalmars-d mailing list