digitalmars.D - module hijacking
- Andrei Alexandrescu (18/18) Oct 31 2009 I ran the following experiment:
- davidl (12/30) Nov 01 2009 There must be some bug reports related to this issue, at least mine. But...
- hasenj (3/28) Nov 01 2009 This is also possible in python.
- Rainer Deyke (6/9) Nov 01 2009 In Python, this has caused problems for me. It's less likely to cause a
- bearophile (5/6) Nov 01 2009 Yes, this is a real problem, that in Python has caused a little wasting ...
- Andrei Alexandrescu (3/33) Nov 01 2009 I just must describe things clearly one way or the other in TDPL.
- Steven Schveighoffer (6/23) Nov 02 2009 No. This is completely the opposite of hijacking. I would consider it ...
- Andrei Alexandrescu (4/35) Nov 02 2009 The opposite of hijacking would be if any duplicates found would be an
- Steven Schveighoffer (12/44) Nov 02 2009 No, this is also a form of hijacking -- namespace hijacking.
- Leandro Lucarella (19/36) Nov 02 2009 Maybe this can be addressed by adding relative imports like in Python 2....
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
Oct 31 2009
在 Sun, 01 Nov 2009 13:28:56 +0800,Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> 写道: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 soThere 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? AndreiWe 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/
Nov 01 2009
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? AndreiThis is also possible in python. Has this ever caused a real problem? or is it just a theoretical problem?
Nov 01 2009
hasenj wrote:This is also possible in python. Has this ever caused a real problem? or is it just a theoretical problem?In Python, this has caused problems for me. It's less likely to cause a problem in D because D makes better use of packages. Python just dumps everything into the root package; D has 'std'. -- Rainer Deyke - rainerd eldwood.com
Nov 01 2009
hasenj:Has this ever caused a real problem? or is it just a theoretical problem?Yes, this is a real problem, that in Python has caused a little wasting of time now and then. But it's not a high danger, so we may chose to try to fix it later. And if/when we want to fix/avoid it, we must be careful to not turn the medicine to cure it into something that has side effects worse than the problem itself. Python devs are well aware of this problem (every month a newbie post a problem caused by this), but a lot of time ago they have chosen to not fix it, thinking that the possible solutions are not nice. Bye, bearophile
Nov 01 2009
hasenj wrote:Andrei Alexandrescu wrote:I just must describe things clearly one way or the other in TDPL. AndreiI 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? AndreiThis is also possible in python. Has this ever caused a real problem? or is it just a theoretical problem?
Nov 01 2009
On Sun, 01 Nov 2009 01:28:56 -0400, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> 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?No. This is completely the opposite of hijacking. I would consider it hijacking if I had a project with a blah/file.d and the standard library added a blah/file.d that overrode *my* file. -Steve
Nov 02 2009
Steven Schveighoffer wrote:On Sun, 01 Nov 2009 01:28:56 -0400, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:The opposite of hijacking would be if any duplicates found would be an error. AndreiI 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?No. This is completely the opposite of hijacking. I would consider it hijacking if I had a project with a blah/file.d and the standard library added a blah/file.d that overrode *my* file. -Steve
Nov 02 2009
On Mon, 02 Nov 2009 10:40:50 -0500, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:Steven Schveighoffer wrote:No, this is also a form of hijacking -- namespace hijacking. example: I write an application, defining a small internal library foo. I put a module bar in the foo directory, and import foo.bar in my main program. Now, someone compiles it on his system and happens to have a globally installed foo library (completely unrelated to my app-specific foo library) with a module bar. The compiler sees both and throws an error? Now I have to deal with the possibility that any library can kill the ability to compile my app by naming its directories the same? -SteveOn Sun, 01 Nov 2009 01:28:56 -0400, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:The opposite of hijacking would be if any duplicates found would be an error.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?No. This is completely the opposite of hijacking. I would consider it hijacking if I had a project with a blah/file.d and the standard library added a blah/file.d that overrode *my* file. -Steve
Nov 02 2009
Steven Schveighoffer, el 2 de noviembre a las 10:59 me escribiste:Maybe this can be addressed by adding relative imports like in Python 2.5+ import my_foo = .foo; // look for dirname(__FILE__)/foo.d, error if not found import ..foo: bar; // dirname(__FILE__)/../foo.d, error if not found import foo; // regular search path Relative imports are always aliased or subject to importing single symbols because .foo is not a valid symbol name. I think import ...foo; could be allowed by making it a shortcut to import foo = ...foo; See http://www.python.org/dev/peps/pep-0328/ for the complete proposal. The Python community already had to deal with this (maybe for different reasons though), maybe we can learn something from it. -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- Yo soy peperino el que siempre pone el vino, yo soy aquel que come los huevos con tocino. -- Peperino P贸moroThe opposite of hijacking would be if any duplicates found would be an error.No, this is also a form of hijacking -- namespace hijacking. example: I write an application, defining a small internal library foo. I put a module bar in the foo directory, and import foo.bar in my main program. Now, someone compiles it on his system and happens to have a globally installed foo library (completely unrelated to my app-specific foo library) with a module bar. The compiler sees both and throws an error? Now I have to deal with the possibility that any library can kill the ability to compile my app by naming its directories the same?
Nov 02 2009