[Issue 7830] New: public import is not fully documented

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 5 07:01:27 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7830

           Summary: public import is not fully documented
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: TDPL
          Severity: normal
          Priority: P2
         Component: websites
        AssignedTo: nobody at puremagic.com
        ReportedBy: schveiguy at yahoo.com


--- Comment #0 from Steven Schveighoffer <schveiguy at yahoo.com> 2012-04-05 07:02:03 PDT ---
The current documentation for public import on the spec says only:

An import can be specifically declared public, when it will be treated as if
any imports of the module with the ImportDeclaration also import the public
imported modules.

This is not the full story.  According TDPL, and the current implementation
(all the way back to at least 2.033), a public import also aliases all symbols
from the publicly imported module as if they were declared in the importing
module.

for example:

submodule.d:
module submodule;
void foo() {}

pubimport.d:
module pubimport;
public import submodule;

main.d:
import pubimport;

void main()
{
   pubimport.foo(); // Works!
}

The documentation should be amended with:

In addition, all symbols from the publicly imported module are aliased as if
they were declared in the importing module.

The example should also be amended to demonstrate:

  bar();        // ok, calls B.bar()
+ C.bar();      // ok, calls B.bar(), C aliases all of B's symbols

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list