Nested function declarations

bearophile bearophileHUGS at
Thu Jan 27 15:53:14 PST 2011

This D2 code:

import std.math: sqrt;
void main() {
    double sqrt();
    double result = sqrt(9.0);

Generates the errors:
test.d(4): Error: function test.main.sqrt () is not callable using argument types (double)
test.d(4): Error: expected 0 arguments, not 1 for non-variadic function type double()

What is the purpose of nested function declarations in D? Is it a good idea to just disallow them?

Bye and thank you,

More information about the Digitalmars-d-learn mailing list