digitalmars.D - Cannot import module that has name of a package
- =?UTF-8?B?SGVubnJpY2ggQmzDtmJhdW0=?= (13/13) Mar 22 2007 Hi!
- Frits van Bommel (13/30) Mar 22 2007 class bar {
- =?UTF-8?B?SGVubnJpY2ggQmzDtmJhdW0=?= (3/39) Mar 22 2007 oh yeah... ;)
- J Duncan (10/33) Mar 22 2007 Because its illegal, you could have FQNs that are unable to resolve....
- =?UTF-8?B?SGVubnJpY2ggQmzDtmJhdW0=?= (2/44) Mar 22 2007 Yes, I have seen this, but as style guide says, windows is sadly ignored...
- Chris Nicholson-Sauls (6/51) Mar 22 2007 The near alternative is to have packages /contain/ a module by the same ...
- Don Clugston (7/23) Mar 23 2007 It works fine on Windows. As long as D is case-sensitive, it will work
- psp250 (6/42) Mar 23 2007 Well, in D as well as other languages, such a file structure/example doe...
Hi! Look at this: <main.d> import test.foo; import test.foo.bar; <test/foo.d> module test.foo; <test/foo/bar.d> module test.foo.bar; This gives error: test/foo.d: module test.foo module and package have the same name Is there any reason why this is blocked? Hennrich
Mar 22 2007
Hennrich Blöbaum wrote:Hi! Look at this:[snip]This gives error: test/foo.d: module test.foo module and package have the same name Is there any reason why this is blocked?<test/foo.d> module test.foo;class bar { static void baz() { // ... Some function implementation ... } }<test/foo/bar.d> module test.foo.bar;void baz() { // ... Some completely different function implementation ... }<main.d> import test.foo; import test.foo.bar;void main() { test.foo.bar.baz(); // which function does this call? }
Mar 22 2007
Frits van Bommel schrieb:Hennrich Blöbaum wrote:oh yeah... ;) thanksHi! Look at this:[snip]This gives error: test/foo.d: module test.foo module and package have the same name Is there any reason why this is blocked?> <test/foo.d> > module test.foo; class bar { static void baz() { // ... Some function implementation ... } } > <test/foo/bar.d> > module test.foo.bar; void baz() { // ... Some completely different function implementation ... } > <main.d> > import test.foo; > import test.foo.bar; void main() { test.foo.bar.baz(); // which function does this call? }
Mar 22 2007
Hennrich Blöbaum wrote:Hi! Look at this: <main.d> import test.foo; import test.foo.bar; <test/foo.d> module test.foo; <test/foo/bar.d> module test.foo.bar; This gives error: test/foo.d: module test.foo module and package have the same name Is there any reason why this is blocked? HennrichBecause its illegal, you could have FQNs that are unable to resolve.... I get around this by using uppercase (or camel case) for module names. module test.Foo; - and - module test.foo.Bar; this is a violation of walters suggested style guide, and it will not compile on operating systems that force a single case. But I happen to love the practice, as now I am able to reuse package names for module names.
Mar 22 2007
J Duncan schrieb:Hennrich Blöbaum wrote:Yes, I have seen this, but as style guide says, windows is sadly ignored.Hi! Look at this: <main.d> import test.foo; import test.foo.bar; <test/foo.d> module test.foo; <test/foo/bar.d> module test.foo.bar; This gives error: test/foo.d: module test.foo module and package have the same name Is there any reason why this is blocked? HennrichBecause its illegal, you could have FQNs that are unable to resolve.... I get around this by using uppercase (or camel case) for module names. module test.Foo; - and - module test.foo.Bar; this is a violation of walters suggested style guide, and it will not compile on operating systems that force a single case. But I happen to love the practice, as now I am able to reuse package names for module names.
Mar 22 2007
Hennrich Blöbaum wrote:J Duncan schrieb:The near alternative is to have packages /contain/ a module by the same name. module test.foo.Foo ; module test.bar.Bar ; It has always felt really awkward to me, though. -- Chris Nicholson-SaulsHennrich Blöbaum wrote:Yes, I have seen this, but as style guide says, windows is sadly ignored.Hi! Look at this: <main.d> import test.foo; import test.foo.bar; <test/foo.d> module test.foo; <test/foo/bar.d> module test.foo.bar; This gives error: test/foo.d: module test.foo module and package have the same name Is there any reason why this is blocked? HennrichBecause its illegal, you could have FQNs that are unable to resolve.... I get around this by using uppercase (or camel case) for module names. module test.Foo; - and - module test.foo.Bar; this is a violation of walters suggested style guide, and it will not compile on operating systems that force a single case. But I happen to love the practice, as now I am able to reuse package names for module names.
Mar 22 2007
Hennrich Blöbaum wrote:Such as?I get around this by using uppercase (or camel case) for module names. module test.Foo; - and - module test.foo.Bar; this is a violation of walters suggested style guide, and it will not compile on operating systems that force a single case.But I happen toIt works fine on Windows. As long as D is case-sensitive, it will work even if the OS is case-insensitive. You just need a module statement so that D knows what the correct case-sensitive name is. And when creating the file, you need to use the correct capitalisation so that it will work on case-sensitive OSes.love the practice, as now I am able to reuse package names for module names.Yes, I have seen this, but as style guide says, windows is sadly ignored.
Mar 23 2007
Frits van Bommel Wrote:Hennrich Blöbaum wrote:Well, in D as well as other languages, such a file structure/example does not get past compilation and results in a symbol collision. From earlier experiments I know you could compile both modules individually and use a combined header file to attempt to link the object files which would give you a symbol collision error. As reports if you have no collision, it works. So why can't D rather report such collisions at compile time or linking instead? The current way in my point limits the way you can structure your D projects and is something which other languages do better. I think it could greatly enhance maintainability for D file hierarchies (and move it away from the currently really C-like module layouts).Hi! Look at this:[snip]This gives error: test/foo.d: module test.foo module and package have the same name Is there any reason why this is blocked?> <test/foo.d> > module test.foo; class bar { static void baz() { // ... Some function implementation ... } } > <test/foo/bar.d> > module test.foo.bar; void baz() { // ... Some completely different function implementation ... } > <main.d> > import test.foo; > import test.foo.bar; void main() { test.foo.bar.baz(); // which function does this call? }
Mar 23 2007