Property discussion wrap-up
Zach the Mystic
reachBUTMINUSTHISzach at gOOGLYmail.com
Tue Jan 29 21:20:50 PST 2013
On Tuesday, 29 January 2013 at 18:54:09 UTC, H. S. Teoh wrote:
> I agree with all of this, except that currently, as things
> stand, we
> can't actually implement certain kinds of properties as
> structs, because
> nested structs do not have access to their parent lexical scope:
>
> 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;
> }
You know, I was too dumb to even understand what you wrote when I
read it the first time. I was just naively assuming that nested
structs were like nested functions. Some rules definitely need to
be figured out here. I don't see why the basic functionality
which is provided for nested functions couldn't work also for
nested structs. Does "static struct" mean anything here? Couldn't
it be used exactly like static nested functions? Would it break
code if we now forced people to say "static struct" instead of
just struct?
I'm sorry for missing your point. I'm trying to suggest advanced
language features without even knowing some of the basics. I ask
you to bear with me.
More information about the Digitalmars-d
mailing list