http://d.puremagic.com/issues/show_bug.cgi?id=7459
Summary: working around nested function declaration order Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: spec Severity: enhancement Priority: P2 Component: websites AssignedTo: nob...@puremagic.com ReportedBy: timon.g...@gmx.ch --- Comment #0 from timon.g...@gmx.ch 2012-02-07 11:04:28 PST --- d-programming-language.org/function sez: Unlike module level declarations, declarations within function scope are processed in order. This means that two nested functions cannot mutually call each other: void test() { void foo() { bar(); } // error, bar not defined void bar() { foo(); } // ok } The solution is to use a delegate: void test() { void delegate() fp; void foo() { fp(); } void bar() { foo(); } fp = &bar; } The proposed solution is unnecessarily complicated and non-optimal. Since nested template functions are instantiated with the state of the symbol table of the lexically first instantiation, this is a superior solution: void test() { void foo()() { bar(); } // ok void bar() { foo(); } // ok } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------