Dot syntax to access static variables of functions
bearophile
bearophileHUGS at lycos.com
Fri Dec 16 17:37:54 PST 2011
Timon Gehr:
> Local variables are not part of the function interface. They are
> implementation details.
What I have proposed is just about static variables of functions, not all local variables.
-----------------
Sean Kelly:
> struct foo {
> __gshared int x = 10;
> static void opCall() {
> // uses x
> writeln("foo");
> }
> }
>
> void main() {
> auto fptr = foo; // sad that the syntax has to change here
> fptr();
> auto y = foo.x; // uses foo.x
> }
I don't know what you were trying to express here (and struct names start with an upper case in D).
Thank you for your answers,
bearophile
More information about the Digitalmars-d
mailing list