www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - new DIP14: Package import path association

reply "Martin Nowak" <dawg dawgfoto.de> writes:
http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP14
Oct 18 2011
next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2011-10-18 09:38, Martin Nowak wrote:
 http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP14
What happens if you import a the same file twice using different paths, i.e. relative and absolute path? Will the imported files need a module declaration or will the compiler just care about the path? -- /Jacob Carlborg
Oct 18 2011
next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
I think the best thing to do would be to maintain a module[path]
mapping, where more then one path can map to a single module.
The by-path import declarations would add items to the mapping and the
compiler would extract the list of modules from it.

On Tue, Oct 18, 2011 at 3:23 PM, Jacob Carlborg <doob me.com> wrote:
 On 2011-10-18 09:38, Martin Nowak wrote:
 http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP14
What happens if you import a the same file twice using different paths, i.e. relative and absolute path? Will the imported files need a module declaration or will the compiler just care about the path? -- /Jacob Carlborg
Oct 18 2011
prev sibling parent reply "Martin Nowak" <dawg dawgfoto.de> writes:
On Tue, 18 Oct 2011 13:23:02 +0200, Jacob Carlborg <doob me.com> wrote:

 On 2011-10-18 09:38, Martin Nowak wrote:
 http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP14
What happens if you import a the same file twice using different paths, i.e. relative and absolute path? Will the imported files need a module declaration or will the compiler just care about the path?
The module name is determined by the module declaration or implicitly by the basename of the file. Module collisions are already detected based on the module name. You can actually import two identical modules through different files/symlinks as long as they don't have a module declaration. This does not differ from the current behavior. martin
Oct 18 2011
parent Jacob Carlborg <doob me.com> writes:
On 2011-10-18 13:48, Martin Nowak wrote:
 On Tue, 18 Oct 2011 13:23:02 +0200, Jacob Carlborg <doob me.com> wrote:

 On 2011-10-18 09:38, Martin Nowak wrote:
 http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP14
What happens if you import a the same file twice using different paths, i.e. relative and absolute path? Will the imported files need a module declaration or will the compiler just care about the path?
The module name is determined by the module declaration or implicitly by the basename of the file. Module collisions are already detected based on the module name. You can actually import two identical modules through different files/symlinks as long as they don't have a module declaration. This does not differ from the current behavior. martin
What happens then, to module constructors and similar? What concerns me is that something similar to Ruby 1.8 could happen. In Ruby when the compiler encounters a "require" it will load the file specified in the require call. Meaning any top level code will be executed. If you require the same file again, i.e. from another file it will not execute the required file again because it's already loaded. The problem with this is that the load path which stores all loaded ruby files does not sore the full path name of a ruby file, it stores what every you called "require" with. If you then require the same file using two different paths, i.e. relative and full path, the required file will be executed again, possibly resulting in warnings like: warning: already initialized constant FOO This is fixed in Ruby 1.9 by always storing full paths to required files in the load path. -- /Jacob Carlborg
Oct 18 2011
prev sibling parent Don <nospam nospam.com> writes:
On 18.10.2011 09:38, Martin Nowak wrote:
 http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP14
Your proposal seems to have an implicit "Posix file path syntax is used", but that opens a can of worms. Up until now, there has been a policy of ensuring that OS-specific paths are kept out of the language.
Oct 18 2011