在 Sun, 01 Nov 2009 13:28:56 +0800,Andrei Alexandrescu <[email protected]> 写道:

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

There must be some bug reports related to this issue, at least mine. But I report it in a way that I didn't aware the cause is this. After I realized the issue, and I was too lazy to change the bug reports.

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

We definitely need to prevent the module level hijacking. But there isn't any effective way of correcting the current behavior. The hijacking can occur especially when you don't handle the build tool correctly, meaning the include path not set correspondingly, while you use both tango and phobos.


--
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/

Reply via email to