Nested function declarations
Tomek Sowiński
just at ask.me
Sat Jan 29 06:29:58 PST 2011
Tomek Sowiński napisał:
> > What is the purpose of nested function declarations in D? Is it a good idea to just disallow them?
>
> 1. Helper functions don't clutter the namespace.
> 2. Nested functions can access the outer function's stack frame.
OK, I just noticed you asked about declarations, not nested functions in general.
They're useful for testing:
unittest {
int foo();
static assert (is(ReturnType!foo == int));
}
--
Tomek
More information about the Digitalmars-d-learn
mailing list