Skip to content

Commit

Permalink
Added documentation for scoped imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
Poita committed Jan 20, 2012
1 parent bd74c4f commit bf370b1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions module.dd
Expand Up @@ -363,6 +363,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 bf370b1

Please sign in to comment.