[Issue 11330] Directory named as imported module should not stop module search

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 27 23:45:54 PDT 2013


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



--- Comment #11 from Walter Bright <bugzilla at digitalmars.com> 2013-10-27 23:45:52 PDT ---
(In reply to comment #9)
> I don't see how a list of search paths is like a number of nested scopes.

It's always been that way, and C and C++ compilers operate the same way. To
override, you put a path in front of the list of paths. The clear hierarchy is
the ones earlier in the list override the ones later, i.e. the "first found"
rule. Just like nested scopes.


> This is besides my argument, anyway, so I understand you're replying about the
> suggestion for module hijack protection?

This was in response to the idea that errors should be generated if a file
appears in more than one path.


> If that's not the case, then it's even more unclear to me why this change was
> introduced, and why it is considered beneficial.

The change was made so that existing modules, like std.algorithm, could be
split into multiple modules without breaking existing code.

See http://wiki.dlang.org/DIP37


> > 2. The import system is designed to map onto the file system. Using
> > file/directory names that match module/package names is how it is supposed to
> > work, if there are matching names that have nothing to do with D will cause
> > problems.
> 
> This does not address my arguments in comment #2.
> 
> Also, without context, your quote can be used to defend a hypothetical change
> in DMD to reject "modulename.txt" files, if they exist in the search path and
> "modulename" is imported somewhere, which is absurd. Which is the main point of
> my argument: D compilers should not treat filesystem directories that match
> imported D modules as if they are made for use for D. ".d" files are for D
> compilers, directories are for everyone.

Directory names have always been regarded as having a 1:1 correspondence with
package names in D. This is not new. std.algorithm corresponds to
std/algorithm.d


> As far as I know, no other implementation of a package system in any other
> language behaves as DMD behaves now.

As I recall, this was debated at length and was implemented months ago.


> I hope this isn't an attempt to sweep a regression under the rug to get 2.064
> out quicker:
> - I have stumbled upon this problem twice, in two different situations.
> - This change affected two other users (issue 11241 and issue 11243).

I am sorry it breaks some existing setups, but the behavior is designed, and is
not a bug. There were several proposals, and this one broke the least and
before this everyone has liked it.

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