On 03/04/12 07:38, Nick Sabalausky wrote:
Regarding this:
http://d.puremagic.com/issues/show_bug.cgi?id=790
I submit that nested functions should be exempt from the usual sequential
visibility rules. (Therefore, mutually recursive nested functions would
become possible.)
Or at the very *least*, this horrific C-like workaround should be possible:
void foo()
{
void b();
void a() {...};
void b() {...};
}
...Flame away! ;)
The most flexible method is to declare a local, nested struct. Any
member functions (and variables!) of that struct have non-sequential
semantics, so they can forward reference each other just fine.
void foo()
{
struct Local
{
static void a() { b(); }
static void b() { };
}
Local.a();
}
If they need to access stack variables, you'll need to create an actual
instance of the struct. You can make it a static struct if they don't
need access to any stack variables of foo.
Note that this completely sidesteps all the nasty issues I mentioned in
other posts.