@@ -224,6 +224,7 @@ $(H3 $(LNAME2 name_lookup, Symbol Name Lookup))
224224 $(P The simplest form of importing is to just list the
225225 modules being imported:)
226226
227+ $(RUNNABLE_EXAMPLE
227228---------
228229module myapp.main;
229230
@@ -239,6 +240,7 @@ class Foo : BaseClass
239240 }
240241}
241242---------
243+ )
242244
243245 $(P When a symbol name is used unqualified, a two-phase lookup will happen.
244246 First, the module scope will be searched, starting from the innermost
@@ -383,6 +385,7 @@ $(H3 $(LNAME2 renamed_imports, Renamed Imports))
383385 all references to the module's symbols must be qualified
384386 with:)
385387
388+ $(RUNNABLE_EXAMPLE
386389---
387390import io = std.stdio;
388391
@@ -393,6 +396,7 @@ void main()
393396 writeln("hello!"); // error, writeln is undefined
394397}
395398---
399+ )
396400
397401 $(P Renamed imports are handy when dealing with
398402 very long import names.)
@@ -402,6 +406,7 @@ $(H3 $(LNAME2 selective_imports, Selective Imports))
402406 $(P Specific symbols can be exclusively imported from
403407 a module and bound into the current namespace:)
404408
409+ $(RUNNABLE_EXAMPLE
405410---
406411import std.stdio : writeln, foo = write;
407412
@@ -414,13 +419,15 @@ void main()
414419 fwritefln(stdout, "abc"); // error, fwritefln undefined
415420}
416421---
422+ )
417423
418424 $(P $(D static) cannot be used with selective imports.)
419425
420426$(H3 $(LNAME2 renamed_selective_imports, Renamed and Selective Imports))
421427
422428 $(P When renaming and selective importing are combined:)
423429
430+ $(RUNNABLE_EXAMPLE
424431------------
425432import io = std.stdio : foo = writeln;
426433
@@ -437,19 +444,22 @@ void main()
437444 // foo is not a member of io
438445}
439446--------------
447+ )
440448
441449
442450$(H3 $(LNAME2 scoped_imports, Scoped Imports))
443451
444452 $(P Import declarations may be used at any scope. For example:)
445453
454+ $(RUNNABLE_EXAMPLE
446455--------------
447456void main()
448457{
449458 import std.stdio;
450459 writeln("bar");
451460}
452461--------------
462+ )
453463
454464 $(P The imports are looked up to satisfy any unresolved symbols at that scope.
455465 Imported symbols may hide symbols from outer scopes.)
@@ -461,6 +471,7 @@ void main()
461471 at function scope cannot be forward referenced.
462472 )
463473
474+ $(RUNNABLE_EXAMPLE
464475--------------
465476void main()
466477{
@@ -477,6 +488,7 @@ void main()
477488 std.stdio.writeln("bar"); // error, std is undefined
478489}
479490--------------
491+ )
480492
481493
482494
0 commit comments