[Issue 9664] New: Make directory in import path like "a.b.c" a properly supported feature

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 8 02:48:37 PST 2013


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

           Summary: Make directory in import path like "a.b.c" a properly
                    supported feature
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: jfanatiker at gmx.at


--- Comment #0 from jfanatiker at gmx.at 2013-03-08 02:48:35 PST ---
I just made the discovery that putting a D source file named "d" in a
directory named "a.b.c" with a module declaration like:
 module a.b.c.d;

works as expected (can be imported via import a.b.c.d;). This is
actually pretty cool and useful, because there are times where you end up
having a directory containing a single directory containing a single directory,
..., just because of the module path. Having to traverse three folders just to
get to the source code could easily be avoided if this was actually an official
feature.

At the moment this only works if you provide the imported module at the command
line, but not if you only provide -I and just compile with -c:


 dmd -c main.d
 main.d(1): Error: module t is in file 'a/b/c/d.d' which cannot be read
 import path[0] = /usr/include/dmd/phobos
 import path[1] = /usr/include/dmd/druntime/import

while this is fine:
 dmd main.d a.b.c/d.d

I think it might be a good idea having the compiler fallback to a folder a.b.c
if it exists (or a.b). It could simply prefer a/b/c over a.b/c over a.b.c. In
practice only one of them should exist anyway, so the compiler could also just
issue an error if ambiguous.

-- 
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