Skip to content

Instantly share code, notes, and snippets.

@schveiguy schveiguy/ex1_a.d
Last active Aug 29, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.