On Dec 15, 2011, at 3:48 PM, bearophile wrote: > In some cases I use a global variable only from a small small number of > functions, like foo() and main() here: > > > import std.stdio; > __gshared static int x = 10; > void foo() { > // uses x > writeln("foo"); > } > void main() { > auto fptr = &foo; > fptr(); > auto y = x; // uses x > } > > > To write more tidy code in some of those situations I'd like a dot syntax to > access static variables of a function: > > void foo() { > __gshared static int x = 10; > // uses x > writeln("foo"); > } > void main() { > auto fptr = &foo; > fptr(); > auto y = foo.x; // uses foo.x > }
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 }