Re: Forward reference to nested function not allowed?

2014-06-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 31 May 2014 16:18:33 + DLearner via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, import std.stdio; void main() { writefln(Entered); sub1(); sub1(); sub1(); writefln(Returning); void sub1() { static int i2 = 6;

Forward reference to nested function not allowed?

2014-05-31 Thread DLearner via Digitalmars-d-learn
Hi, import std.stdio; void main() { writefln(Entered); sub1(); sub1(); sub1(); writefln(Returning); void sub1() { static int i2 = 6; i2 = i2 + 1; writefln(%s,i2); }; } does not compile, but import std.stdio; void main() { void sub1() {

Re: Forward reference to nested function not allowed?

2014-05-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 31 May 2014 at 16:18:35 UTC, DLearner wrote: Is this intended? Yes, nested functions access local variables and thus follow the same order of declaration rules as they do; you can't use a local variable before it is declared so same with a nested function.

Re: Forward reference to nested function not allowed?

2014-05-31 Thread Philippe Sigaud via Digitalmars-d-learn
See: http://dlang.org/function.html#variadicnested The second example explains that nested functions can be accessed only if the name is in scope.