digitalmars.D - Package Import
- DemmeGod (8/8) May 10 2004 In D, is it possible to import an entire package? Better yet, is it
- J Anderson (6/15) May 11 2004 What I would do to break things is put all the classes you need to be
- DemmeGod (7/26) May 11 2004 When you say link them together, how do you mean? Do you mean use a ton...
- J Anderson (4/38) May 11 2004 Yes just don't have the word private infront.
- Phill (8/14) May 11 2004 A module is more or less a file.
- DemmeGod (5/24) May 11 2004 I've read the specs... I understand that, however is one does it that w...
- Regan Heath (35/62) May 11 2004 You mean something like this...
- DemmeGod (55/135) May 11 2004 That's precisely what I mean... I get a compile error with something sim...
- Regan Heath (41/174) May 11 2004 What are you writing it in? I am using DIDE which works quite well, you
- DemmeGod (6/209) May 11 2004 Thats not quite accurate... You'll get a compile error if you move modul...
- Regan Heath (8/223) May 11 2004 Indeed, an "import com package and module have the same name" error.
- J C Calvarese (16/166) May 11 2004 There's a limitation in the way D's modules work: you can't have a
- DemmeGod (5/177) May 11 2004 No, I don't need to have it that way, I'd just prefer it. I haven't see...
- Phill (5/9) May 11 2004 way,
In D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, since it appears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie? Thanks in advance Demme
May 10 2004
DemmeGod wrote:In D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, since it appears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie? Thanks in advance DemmeWhat I would do to break things is put all the classes you need to be friends (normally quite rare), in the same module. Everything else can can go in other modules and you can link them together using import. -- -Anderson: http://badmama.com.au/~anderson/
May 11 2004
J Anderson wrote:DemmeGod wrote:When you say link them together, how do you mean? Do you mean use a ton of imports in each file that is using them? Or is it possible to import modules into another module, which will in turn be imported when one wishes to use all of the modules? Thanks DemmeIn D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, since it appears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie? Thanks in advance DemmeWhat I would do to break things is put all the classes you need to be friends (normally quite rare), in the same module. Everything else can can go in other modules and you can link them together using import.
May 11 2004
DemmeGod wrote:J Anderson wrote:Yes just don't have the word private infront. -- -Anderson: http://badmama.com.au/~anderson/DemmeGod wrote:When you say link them together, how do you mean? Do you mean use a ton of imports in each file that is using them? Or is it possible to import modules into another module, which will in turn be imported when one wishes to use all of the modules? Thanks DemmeIn D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, since it appears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie? Thanks in advance DemmeWhat I would do to break things is put all the classes you need to be friends (normally quite rare), in the same module. Everything else can can go in other modules and you can link them together using import.
May 11 2004
A module is more or less a file. You can have one module foreach class if you want. Take a look at this URL: http://www.digitalmars.com/d/module.html Phill. "DemmeGod" <me demmegod.com> wrote in message news:c7pnss$28ea$1 digitaldaemon.com...In D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, sinceitappears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie?
May 11 2004
I've read the specs... I understand that, however is one does it that way, one must import each class that one indends on using. My question was if it was possible to import an entire class, that is import a whole bunch on modules. I take it that this is not possible? Phill wrote:A module is more or less a file. You can have one module foreach class if you want. Take a look at this URL: http://www.digitalmars.com/d/module.html Phill. "DemmeGod" <me demmegod.com> wrote in message news:c7pnss$28ea$1 digitaldaemon.com...In D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, sinceitappears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie?
May 11 2004
On Tue, 11 May 2004 13:23:59 -0400, DemmeGod <me demmegod.com> wrote:I've read the specs... I understand that, however is one does it that way, one must import each class that one indends on using. My question was if it was possible to import an entire class, that is import a whole bunch on modules. I take it that this is not possible?You mean something like this... import module1; [test.d] import std.string; import module1; int main () { m1(5); m2(8); m3(9); return 0; } [module1.d] module module1; import module2; import module3; void m1(int a) { printf("module1: %d\n",a); m2(++a); m3(++a); } [module2.d] module module2; void m2(int a) { printf("module2: %d\n",a); } [module3.d] module module3; void m3(int a) { printf("module3: %d\n",a); } i.e. importing module1 implicitly imports modules 2 and 3. Regan.Phill wrote:-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/A module is more or less a file. You can have one module foreach class if you want. Take a look at this URL: http://www.digitalmars.com/d/module.html Phill. "DemmeGod" <me demmegod.com> wrote in message news:c7pnss$28ea$1 digitaldaemon.com...In D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, sinceitappears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie?
May 11 2004
That's precisely what I mean... I get a compile error with something similar to that, however. I figure I'd write a lightweight logger: [com/demmegod/lwLog4D.d] module com.demmegod.lwLog4D; import com.demmegod.lwLog4D.Logger; [com/demmegod/lwLog4D/Logger.d] module com.demmegod.lwLog4D.Logger; import com.demmegod.lwLog4D; class Logger { Appender[] appenders = []; static Logger globalLogger; static Logger getGlobalLogger() { ... } static void setGlobalLogger(Logger _globalLogger) { ... } this() { ... } void log(LogPriority priority, char[] message) { ... } void addAppender(Appender appender) { ... } void removeAppender(Appender appender) { ... } } ...Plus more classes... When I try to compile lwLog4D.d, I get the following error: com/demmegod/lwLog4D.d(1): module lwLog4D module and package have the same name I assumed that meant that I couldn't import com.demmegod.lwLog4D.Logger. I'd like to import com.demmegod.lwLog4D and have access to multiple classes in separate files (Logger being one example.) Yes, I know I'm violating convention by using upper case characters in the module and package names... I'll change that. Thanks Regan Heath wrote:On Tue, 11 May 2004 13:23:59 -0400, DemmeGod <me demmegod.com> wrote:I've read the specs... I understand that, however is one does it that way, one must import each class that one indends on using. My question was if it was possible to import an entire class, that is import a whole bunch on modules. I take it that this is not possible?You mean something like this... import module1; [test.d] import std.string; import module1; int main () { m1(5); m2(8); m3(9); return 0; } [module1.d] module module1; import module2; import module3; void m1(int a) { printf("module1: %d\n",a); m2(++a); m3(++a); } [module2.d] module module2; void m2(int a) { printf("module2: %d\n",a); } [module3.d] module module3; void m3(int a) { printf("module3: %d\n",a); } i.e. importing module1 implicitly imports modules 2 and 3. Regan.Phill wrote:A module is more or less a file. You can have one module foreach class if you want. Take a look at this URL: http://www.digitalmars.com/d/module.html Phill. "DemmeGod" <me demmegod.com> wrote in message news:c7pnss$28ea$1 digitaldaemon.com...In D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, sinceitappears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie?
May 11 2004
What are you writing it in? I am using DIDE which works quite well, you can get it here: http://www.atari-soldiers.com/dide.html Here is a cut down code sample that compiles and runs, it does what you are trying to do (I think): [test.d] import std.string; import com.demmegod.module2; int main () { Module2 m = new Module2(); m.m(0); return 0; } [/com/demmegod/module2.d] module com.demmegod.module2; import com.demmegod.module3; class Module2 { void m(int a) { printf("module2: %d\n",a); if ( a < 100 ) { Module3 m = new Module3(); m.m(++a); } } } [/com/demmegod/module3.d] module com.demmegod.module3; import com.demmegod.module2; class Module3 { void m(int a) { printf("module3: %d\n",a); if ( a < 100 ) { Module2 m = new Module2(); m.m(++a); } } } Regan. On Tue, 11 May 2004 20:04:32 -0400, DemmeGod <me demmegod.com> wrote:That's precisely what I mean... I get a compile error with something similar to that, however. I figure I'd write a lightweight logger: [com/demmegod/lwLog4D.d] module com.demmegod.lwLog4D; import com.demmegod.lwLog4D.Logger; [com/demmegod/lwLog4D/Logger.d] module com.demmegod.lwLog4D.Logger; import com.demmegod.lwLog4D; class Logger { Appender[] appenders = []; static Logger globalLogger; static Logger getGlobalLogger() { ... } static void setGlobalLogger(Logger _globalLogger) { ... } this() { ... } void log(LogPriority priority, char[] message) { ... } void addAppender(Appender appender) { ... } void removeAppender(Appender appender) { ... } } ...Plus more classes... When I try to compile lwLog4D.d, I get the following error: com/demmegod/lwLog4D.d(1): module lwLog4D module and package have the same name I assumed that meant that I couldn't import com.demmegod.lwLog4D.Logger. I'd like to import com.demmegod.lwLog4D and have access to multiple classes in separate files (Logger being one example.) Yes, I know I'm violating convention by using upper case characters in the module and package names... I'll change that. Thanks Regan Heath wrote:-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/On Tue, 11 May 2004 13:23:59 -0400, DemmeGod <me demmegod.com> wrote:I've read the specs... I understand that, however is one does it that way, one must import each class that one indends on using. My question was if it was possible to import an entire class, that is import a whole bunch on modules. I take it that this is not possible?You mean something like this... import module1; [test.d] import std.string; import module1; int main () { m1(5); m2(8); m3(9); return 0; } [module1.d] module module1; import module2; import module3; void m1(int a) { printf("module1: %d\n",a); m2(++a); m3(++a); } [module2.d] module module2; void m2(int a) { printf("module2: %d\n",a); } [module3.d] module module3; void m3(int a) { printf("module3: %d\n",a); } i.e. importing module1 implicitly imports modules 2 and 3. Regan.Phill wrote:A module is more or less a file. You can have one module foreach class if you want. Take a look at this URL: http://www.digitalmars.com/d/module.html Phill. "DemmeGod" <me demmegod.com> wrote in message news:c7pnss$28ea$1 digitaldaemon.com...In D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, sinceitappears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie?
May 11 2004
Thats not quite accurate... You'll get a compile error if you move module3 to com.demmegod.module2.module3. DIDE looks nice, but it also looks like it's Windows only. I'm Linux and OSX only. Thanks Regan Heath wrote:What are you writing it in? I am using DIDE which works quite well, you can get it here: http://www.atari-soldiers.com/dide.html Here is a cut down code sample that compiles and runs, it does what you are trying to do (I think): [test.d] import std.string; import com.demmegod.module2; int main () { Module2 m = new Module2(); m.m(0); return 0; } [/com/demmegod/module2.d] module com.demmegod.module2; import com.demmegod.module3; class Module2 { void m(int a) { printf("module2: %d\n",a); if ( a < 100 ) { Module3 m = new Module3(); m.m(++a); } } } [/com/demmegod/module3.d] module com.demmegod.module3; import com.demmegod.module2; class Module3 { void m(int a) { printf("module3: %d\n",a); if ( a < 100 ) { Module2 m = new Module2(); m.m(++a); } } } Regan. On Tue, 11 May 2004 20:04:32 -0400, DemmeGod <me demmegod.com> wrote:That's precisely what I mean... I get a compile error with something similar to that, however. I figure I'd write a lightweight logger: [com/demmegod/lwLog4D.d] module com.demmegod.lwLog4D; import com.demmegod.lwLog4D.Logger; [com/demmegod/lwLog4D/Logger.d] module com.demmegod.lwLog4D.Logger; import com.demmegod.lwLog4D; class Logger { Appender[] appenders = []; static Logger globalLogger; static Logger getGlobalLogger() { ... } static void setGlobalLogger(Logger _globalLogger) { ... } this() { ... } void log(LogPriority priority, char[] message) { ... } void addAppender(Appender appender) { ... } void removeAppender(Appender appender) { ... } } ...Plus more classes... When I try to compile lwLog4D.d, I get the following error: com/demmegod/lwLog4D.d(1): module lwLog4D module and package have the same name I assumed that meant that I couldn't import com.demmegod.lwLog4D.Logger. I'd like to import com.demmegod.lwLog4D and have access to multiple classes in separate files (Logger being one example.) Yes, I know I'm violating convention by using upper case characters in the module and package names... I'll change that. Thanks Regan Heath wrote:On Tue, 11 May 2004 13:23:59 -0400, DemmeGod <me demmegod.com> wrote:I've read the specs... I understand that, however is one does it that way, one must import each class that one indends on using. My question was if it was possible to import an entire class, that is import a whole bunch on modules. I take it that this is not possible?You mean something like this... import module1; [test.d] import std.string; import module1; int main () { m1(5); m2(8); m3(9); return 0; } [module1.d] module module1; import module2; import module3; void m1(int a) { printf("module1: %d\n",a); m2(++a); m3(++a); } [module2.d] module module2; void m2(int a) { printf("module2: %d\n",a); } [module3.d] module module3; void m3(int a) { printf("module3: %d\n",a); } i.e. importing module1 implicitly imports modules 2 and 3. Regan.Phill wrote:A module is more or less a file. You can have one module foreach class if you want. Take a look at this URL: http://www.digitalmars.com/d/module.html Phill. "DemmeGod" <me demmegod.com> wrote in message news:c7pnss$28ea$1 digitaldaemon.com...In D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, sinceitappears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie?
May 11 2004
On Tue, 11 May 2004 21:00:58 -0400, DemmeGod <me demmegod.com> wrote:Thats not quite accurate... You'll get a compile error if you move module3 to com.demmegod.module2.module3.Indeed, an "import com package and module have the same name" error. You can get rid of that by renaming either the directory (AKA the package) or the module (AKA the file).DIDE looks nice, but it also looks like it's Windows only. I'm Linux and OSX only.Ahh.. oh well. Regan.Thanks Regan Heath wrote:-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/What are you writing it in? I am using DIDE which works quite well, you can get it here: http://www.atari-soldiers.com/dide.html Here is a cut down code sample that compiles and runs, it does what you are trying to do (I think): [test.d] import std.string; import com.demmegod.module2; int main () { Module2 m = new Module2(); m.m(0); return 0; } [/com/demmegod/module2.d] module com.demmegod.module2; import com.demmegod.module3; class Module2 { void m(int a) { printf("module2: %d\n",a); if ( a < 100 ) { Module3 m = new Module3(); m.m(++a); } } } [/com/demmegod/module3.d] module com.demmegod.module3; import com.demmegod.module2; class Module3 { void m(int a) { printf("module3: %d\n",a); if ( a < 100 ) { Module2 m = new Module2(); m.m(++a); } } } Regan. On Tue, 11 May 2004 20:04:32 -0400, DemmeGod <me demmegod.com> wrote:That's precisely what I mean... I get a compile error with something similar to that, however. I figure I'd write a lightweight logger: [com/demmegod/lwLog4D.d] module com.demmegod.lwLog4D; import com.demmegod.lwLog4D.Logger; [com/demmegod/lwLog4D/Logger.d] module com.demmegod.lwLog4D.Logger; import com.demmegod.lwLog4D; class Logger { Appender[] appenders = []; static Logger globalLogger; static Logger getGlobalLogger() { ... } static void setGlobalLogger(Logger _globalLogger) { ... } this() { ... } void log(LogPriority priority, char[] message) { ... } void addAppender(Appender appender) { ... } void removeAppender(Appender appender) { ... } } ...Plus more classes... When I try to compile lwLog4D.d, I get the following error: com/demmegod/lwLog4D.d(1): module lwLog4D module and package have the same name I assumed that meant that I couldn't import com.demmegod.lwLog4D.Logger. I'd like to import com.demmegod.lwLog4D and have access to multiple classes in separate files (Logger being one example.) Yes, I know I'm violating convention by using upper case characters in the module and package names... I'll change that. Thanks Regan Heath wrote:On Tue, 11 May 2004 13:23:59 -0400, DemmeGod <me demmegod.com> wrote:I've read the specs... I understand that, however is one does it that way, one must import each class that one indends on using. My question was if it was possible to import an entire class, that is import a whole bunch on modules. I take it that this is not possible?You mean something like this... import module1; [test.d] import std.string; import module1; int main () { m1(5); m2(8); m3(9); return 0; } [module1.d] module module1; import module2; import module3; void m1(int a) { printf("module1: %d\n",a); m2(++a); m3(++a); } [module2.d] module module2; void m2(int a) { printf("module2: %d\n",a); } [module3.d] module module3; void m3(int a) { printf("module3: %d\n",a); } i.e. importing module1 implicitly imports modules 2 and 3. Regan.Phill wrote:A module is more or less a file. You can have one module foreach class if you want. Take a look at this URL: http://www.digitalmars.com/d/module.html Phill. "DemmeGod" <me demmegod.com> wrote in message news:c7pnss$28ea$1 digitaldaemon.com...In D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, sinceitappears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie?
May 11 2004
DemmeGod wrote:That's precisely what I mean... I get a compile error with something similar to that, however. I figure I'd write a lightweight logger: [com/demmegod/lwLog4D.d] module com.demmegod.lwLog4D; import com.demmegod.lwLog4D.Logger; [com/demmegod/lwLog4D/Logger.d] module com.demmegod.lwLog4D.Logger;There's a limitation in the way D's modules work: you can't have a folder and a .d file with the same name in your import scheme. (I don't think this limitation is documented in the spec.) I don't know if Walter is convinced it has to be this way, but others have run into this same situation. If you change it, it'll work. [com/demmegod/lwLog4D.d] --> [com/demmegod/lwLog4D/main.d] module com.demmegod.lwLog4D; --> module com.demmegod.lwLog4D.main; If you don't change it, it won't work. If you have to have it as you originally wrote it, I'd recommend posting a bug report in digitalmars.d.bugs (and it wouldn't hurt to explain why you need this specific arrangement).import com.demmegod.lwLog4D; class Logger { Appender[] appenders = []; static Logger globalLogger; static Logger getGlobalLogger() { ... } static void setGlobalLogger(Logger _globalLogger) { ... } this() { ... } void log(LogPriority priority, char[] message) { ... } void addAppender(Appender appender) { ... } void removeAppender(Appender appender) { ... } } ...Plus more classes... When I try to compile lwLog4D.d, I get the following error: com/demmegod/lwLog4D.d(1): module lwLog4D module and package have the same name I assumed that meant that I couldn't import com.demmegod.lwLog4D.Logger. I'd like to import com.demmegod.lwLog4D and have access to multiple classes in separate files (Logger being one example.) Yes, I know I'm violating convention by using upper case characters in the module and package names... I'll change that. Thanks Regan Heath wrote:-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/On Tue, 11 May 2004 13:23:59 -0400, DemmeGod <me demmegod.com> wrote:I've read the specs... I understand that, however is one does it that way, one must import each class that one indends on using. My question was if it was possible to import an entire class, that is import a whole bunch on modules. I take it that this is not possible?You mean something like this... import module1; [test.d] import std.string; import module1; int main () { m1(5); m2(8); m3(9); return 0; } [module1.d] module module1; import module2; import module3; void m1(int a) { printf("module1: %d\n",a); m2(++a); m3(++a); } [module2.d] module module2; void m2(int a) { printf("module2: %d\n",a); } [module3.d] module module3; void m3(int a) { printf("module3: %d\n",a); } i.e. importing module1 implicitly imports modules 2 and 3. Regan.Phill wrote:A module is more or less a file. You can have one module foreach class if you want. Take a look at this URL: http://www.digitalmars.com/d/module.html Phill. "DemmeGod" <me demmegod.com> wrote in message news:c7pnss$28ea$1 digitaldaemon.com...In D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, sinceitappears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie?
May 11 2004
No, I don't need to have it that way, I'd just prefer it. I haven't seen anything in the specs about that limitation, so I'll post a bug report about it. Thanks Guys J C Calvarese wrote:DemmeGod wrote:That's precisely what I mean... I get a compile error with something similar to that, however. I figure I'd write a lightweight logger: [com/demmegod/lwLog4D.d] module com.demmegod.lwLog4D; import com.demmegod.lwLog4D.Logger; [com/demmegod/lwLog4D/Logger.d] module com.demmegod.lwLog4D.Logger;There's a limitation in the way D's modules work: you can't have a folder and a .d file with the same name in your import scheme. (I don't think this limitation is documented in the spec.) I don't know if Walter is convinced it has to be this way, but others have run into this same situation. If you change it, it'll work. [com/demmegod/lwLog4D.d] --> [com/demmegod/lwLog4D/main.d] module com.demmegod.lwLog4D; --> module com.demmegod.lwLog4D.main; If you don't change it, it won't work. If you have to have it as you originally wrote it, I'd recommend posting a bug report in digitalmars.d.bugs (and it wouldn't hurt to explain why you need this specific arrangement).import com.demmegod.lwLog4D; class Logger { Appender[] appenders = []; static Logger globalLogger; static Logger getGlobalLogger() { ... } static void setGlobalLogger(Logger _globalLogger) { ... } this() { ... } void log(LogPriority priority, char[] message) { ... } void addAppender(Appender appender) { ... } void removeAppender(Appender appender) { ... } } ...Plus more classes... When I try to compile lwLog4D.d, I get the following error: com/demmegod/lwLog4D.d(1): module lwLog4D module and package have the same name I assumed that meant that I couldn't import com.demmegod.lwLog4D.Logger. I'd like to import com.demmegod.lwLog4D and have access to multiple classes in separate files (Logger being one example.) Yes, I know I'm violating convention by using upper case characters in the module and package names... I'll change that. Thanks Regan Heath wrote:On Tue, 11 May 2004 13:23:59 -0400, DemmeGod <me demmegod.com> wrote:I've read the specs... I understand that, however is one does it that way, one must import each class that one indends on using. My question was if it was possible to import an entire class, that is import a whole bunch on modules. I take it that this is not possible?You mean something like this... import module1; [test.d] import std.string; import module1; int main () { m1(5); m2(8); m3(9); return 0; } [module1.d] module module1; import module2; import module3; void m1(int a) { printf("module1: %d\n",a); m2(++a); m3(++a); } [module2.d] module module2; void m2(int a) { printf("module2: %d\n",a); } [module3.d] module module3; void m3(int a) { printf("module3: %d\n",a); } i.e. importing module1 implicitly imports modules 2 and 3. Regan.Phill wrote:A module is more or less a file. You can have one module foreach class if you want. Take a look at this URL: http://www.digitalmars.com/d/module.html Phill. "DemmeGod" <me demmegod.com> wrote in message news:c7pnss$28ea$1 digitaldaemon.com...In D, is it possible to import an entire package? Better yet, is it possible to break up a module into several files? I rather like Java's method of packaging, however D's method seems somewhat cumbersome, sinceitappears to me that all of a module's classes must be in a single file. I don't trust my version control system's merging algorithm that much. Or am I completely missing something, as a D newbie?
May 11 2004
"DemmeGod" <me demmegod.com> wrote in message news:c7r27f$15qf$1 digitaldaemon.com...I've read the specs... I understand that, however is one does it thatway,one must import each class that one indends on using. My question was if it was possible to import an entire class, that is import a whole bunch on modules. I take it that this is not possible?If you mean you want to import "a whole bunch of modules" then Regans way is the way to go.
May 11 2004