@property - take it behind the woodshed and shoot it?

Adam D. Ruppe destructionator at gmail.com
Thu Jan 24 14:37:57 PST 2013


On Thursday, 24 January 2013 at 22:27:02 UTC, Robert wrote:
> @property int a;
>
> would be completely equivalent to: <snip>

Not bad.

> Another thing I am wondering, will this still be possible:
>
> void myProperty(int a) @property {}
>
> void function(int) dg=&myProperty;

If I get things my way, no. I'd rewrite that, internally, into 
&(myProperty()), and then, (unless it returns ref), you'd get an 
error about can't take address of an rvalue.

There'd be no way, under my preference, to treat a property like 
a function at all.

> I think it would be quite sensible and useful

Indeed, but there's an easy alternative too that works with both 
kinds of data, properties and regular: wrapping it in an function 
at the usage site, e.g. "(a) => myProp = a;"


More information about the Digitalmars-d mailing list