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

--- Comment #0 from 2012-02-07 11:04:28 PST --- 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:
------- You are receiving this mail because: -------

Reply via email to