DIP28, on properties, availabel for destruction as well

deadalnix deadalnix at gmail.com
Thu Feb 28 18:42:48 PST 2013


On Thursday, 28 February 2013 at 14:55:06 UTC, angel wrote:
> There _is_ reason.
> You may, possibly, argue this reason is not important enough - 
> here you might be right or wrong, I don't know.
> The point is a @property should behave as close as possible to 
> a real variable:
>
> class A {
>     int field;
> }
> auto a = new A();
> auto x = a.field = 3;
>
> Now you 'upgrade' 'field' to a @property
>
> class A {
>     int _field;
>     @property ??? field(int val) {
>         _field = val;

return _field = val;

>     }
> }
> auto a = new A();
> auto x = a.field = 3;
> The above line should behave _identically_ to the previous case.
> Will it, if you define "@property char field(int val)" ? 
> Apparently no.

The current proposal is simpler and allow more. It surely does 
allow to do crazy stupid things, but you can't really allow more 
without allowing to do dumb things.


More information about the Digitalmars-d mailing list