Skip to content

Instantly share code, notes, and snippets.

@sgraf812
Created January 22, 2019 09:54
Show Gist options
  • Save sgraf812/24f7161b3bebd6fef90897bae911597a to your computer and use it in GitHub Desktop.
Save sgraf812/24f7161b3bebd6fef90897bae911597a to your computer and use it in GitHub Desktop.
Circular module dependencies in D
module a;
import b;
import std.stdio;
struct Flip { Flop* p; }
auto flip(int i) {
if (i == 0) return null;
auto f = new Flip;
f.p = flop(i-1);
return f;
}
void main() {
writefln("Hi %s", *flip(3));
}
module b;
import a;
struct Flop { Flip* p; }
auto flop(int i) {
if (i == 0) return null;
auto f = new Flop;
f.p = flip(i-1);
return f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment