Skip to content

Commit

Permalink
Merge pull request #65 from Poita/local-import
Browse files Browse the repository at this point in the history
Added documentation for scoped imports.
  • Loading branch information
WalterBright committed Jan 24, 2012
2 parents 94dcaab + bf370b1 commit 8107f31
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions module.dd
Expand Up @@ -364,6 +364,33 @@ void main()
// foo is not a member of io
--------------

<h3>Import Scoping</h3>

$(P Import declarations may be used at any scope. For example:)

--------------
void main() {
import std.stdio;
writeln("bar");
}
--------------

$(P The scope of imported symbols is the same as the scope of the import
declaration. Imported symbols may hide symbols from outer scopes.
For example:)

--------------
void main() {
void writeln(string) {}
void foo() {
import std.stdio;
writeln("bar"); // calls std.stdio.writeln
}
writeln("bar"); // calls main.writeln
std.stdio.writeln("bar"); // error, std is undefined
}
--------------

<h3>Module Scope Operator</h3>

Sometimes, it's necessary to override the usual lexical scoping rules
Expand Down

0 comments on commit 8107f31

Please sign in to comment.