Property discussion wrap-up
Zach the Mystic
reachBUTMINUSTHISzach at gOOGLYmail.com
Tue Jan 29 21:44:35 PST 2013
On Tuesday, 29 January 2013 at 18:54:09 UTC, H. S. Teoh wrote:
> class Rectangle {
> float width, height;
>
> // Struct implementation of @property
> struct AreaProp {
> float value() {
> // Error: can't access Rectangle.width
> // and Rectangle.height
> return width*height;
> }
> alias value this;
> ...
> }
> AreaProp area;
> }
Also, I has assumed that opCall or opGet would make more sense
than how you did it:
struct AreaProp {
float opGet() { ... }
...
}
Why "alias this" in your version instead of opCall or opGet?
More information about the Digitalmars-d
mailing list