Last active
August 29, 2016 14:06
-
-
Save schveiguy/bfd3048f7f90353ba04a to your computer and use it in GitHub Desktop.
2.071.0 import article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ex1_a; | |
void foo() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ex1_b; | |
private import ex1_a; // note private is only for illustration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ex1_b; | |
void main() | |
{ | |
ex1_a.foo(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ex2_a; | |
import core.stdc.stdio: printf; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ex2_a; | |
void main() | |
{ | |
printf(""); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.range; | |
void main() | |
{ | |
import std.stdio : write; | |
std.stdio.writeln("hello"); // not actually imported | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ex4_a; | |
int foo() { return 1; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() | |
{ | |
int foo = 5; | |
{ | |
import ex4_a; | |
assert(foo == 5); // fails with dmd prior to 2.071.0 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ex5_a; | |
mixin template foo() | |
{ | |
import std.stdio; | |
void foo() { writeln("foo"); } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ex5_a; | |
mixin template foo() | |
{ | |
import std.stdio : writeln; // now C.bar will work | |
void foo() { writeln("foo"); } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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