Skip to content

Instantly share code, notes, and snippets.

@schveiguy
Last active August 29, 2016 14:06
Show Gist options
  • Save schveiguy/bfd3048f7f90353ba04a to your computer and use it in GitHub Desktop.
Save schveiguy/bfd3048f7f90353ba04a to your computer and use it in GitHub Desktop.
2.071.0 import article
module ex1_a;
void foo() {}
module ex1_b;
private import ex1_a; // note private is only for illustration
import ex1_b;
void main()
{
ex1_a.foo();
}
module ex2_a;
import core.stdc.stdio: printf;
import ex2_a;
void main()
{
printf("");
}
import std.range;
void main()
{
import std.stdio : write;
std.stdio.writeln("hello"); // not actually imported
}
module ex4_a;
int foo() { return 1; }
void main()
{
int foo = 5;
{
import ex4_a;
assert(foo == 5); // fails with dmd prior to 2.071.0
}
}
module ex5_a;
mixin template foo()
{
import std.stdio;
void foo() { writeln("foo"); }
}
module ex5_a;
mixin template foo()
{
import std.stdio : writeln; // now C.bar will work
void foo() { writeln("foo"); }
}
import ex5_a;
class C
{
mixin foo;
void bar()
{
writeln("hello"); // error, writeln symbol not found
}
}
void main()
{
auto c = new C;
c.foo();
c.bar();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment