hasenj wrote:
Andrei Alexandrescu wrote:
I ran the following experiment:
mkdir deleteme
cd deleteme
mkdir std
touch std/algorithm.d
echo 'import std.algorithm; void main(){int a, b;swap(a,b);}' >main.d
dmd main
The attempt to compile main fails with "undefined identifier swap",
which means that the module I defined in the current directory
successfully hijacked the one in the standard library.
The usual D spirit is that a symbol is searched exhaustively, and
attempts at hijacking are denounced. In the module cases, it turns out
that an entire module can successfully hijack another.
Walter and I are ambivalent about this. There has been no bug report
so it seems like people didn't have a problem with things working as
they are. But maybe they never hijacked, or maybe some did hijack.
Question: should we change this?
Andrei
This is also possible in python.
Has this ever caused a real problem? or is it just a theoretical problem?
I just must describe things clearly one way or the other in TDPL.
Andrei