inner functions calling each other - how to do this with inner struct?
Ivan Kazmenko via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Feb 3 15:52:56 PST 2016
On Wednesday, 3 February 2016 at 15:09:35 UTC, Adam D. Ruppe
wrote:
> Read my post here:
>
> http://stackoverflow.com/questions/34398408/struct-declaration-order/34398642#34398642
>
> then see if you can use the same reasoning on your problem.
This indeed works without any other tricks such as compile-time
parameters:
-----
import std.stdio;
void outerFun () {
struct Holder {
static struct S {
void fun2 (int x) {
writeln (x);
if (x > 0) fun1 (x - 1);
}
}
static S s;
static void fun1 (int y) {
writeln (y);
if (y > 1) s.fun2 (y - 2);
}
}
Holder.fun1 (10);
}
void main () {outerFun ();}
-----
Thank you!
Ivan Kazmenko.
More information about the Digitalmars-d-learn
mailing list