Nested functions should be exempt from sequential visibility rules

bearophile bearophileHUGS at lycos.com
Tue Apr 3 06:32:43 PDT 2012


Nick Sabalausky:

> I submit that nested functions should be exempt from the usual 
> sequential
> visibility rules. (Therefore, mutually recursive nested 
> functions would
> become possible.)

What about static nested functions? This seems a simpler
enhancement request:

import std.stdio;
void main() {
    static int male(in int n) pure nothrow {
      return n ? (n - female(male(n - 1))) : 0;
    }
    static int female(in int n) pure nothrow {
      return n ? (n - male(female(n - 1))) : 1;
    }
    writeln(female(15));
}

Bye,
bearophile


More information about the Digitalmars-d mailing list