www.digitalmars.com         C & C++   DMDScript  

D - using modules

reply C <C_member pathlink.com> writes:
It took me a day to figure out that to use modules I had to specify the files in
the compile command.  I just misunderstood the way the import keyword worked.  I
thought it was like #include and the compiler would chain the files before it
compiled.  Maybe I'm just stupid, but shouldn't that be documented somewhere?  I
would have no problem with doing it myself, but how do I get it published on the
D site?

C
Mar 16 2004
next sibling parent J C Calvarese <jcc7 cox.net> writes:
C wrote:
 It took me a day to figure out that to use modules I had to specify the files
in
 the compile command.  I just misunderstood the way the import keyword worked. 
I
 thought it was like #include and the compiler would chain the files before it
 compiled.  Maybe I'm just stupid, but shouldn't that be documented somewhere? 
I
 would have no problem with doing it myself, but how do I get it published on
the
 D site?

That is a common mistake. I know I've done that. I think people have posted bug reports on this. I don't know if Walter would include that in the docs, but I'm sure you could add it to the Wiki4D's FAQ page: http://www.wikiservice.at/d/wiki.cgi?FaqRoadmap.
 
 C

-- Justin http://jcc_7.tripod.com/d/
Mar 16 2004
prev sibling next sibling parent reply "Phill" <phill pacific.net.au> writes:
"C" <C_member pathlink.com> wrote in message
news:c37jjq$1fg6$1 digitaldaemon.com...
 It took me a day to figure out that to use modules I had to specify the

 the compile command.  I just misunderstood the way the import keyword

 thought it was like #include and the compiler would chain the files before

 compiled.  Maybe I'm just stupid, but shouldn't that be documented

 would have no problem with doing it myself, but how do I get it published

 D site?

I remember when I first started learning Java, I could not figure out how to make the packages because there was nothing on the internet about it. It must have been overlooked, which is surprising, considering how very important it is. If you document it, I would definately read it! Phill.
 C

Mar 17 2004
parent "Matthew" <matthew stlsoft.org> writes:
"Phill" <phill pacific.net.au> wrote in message
news:c391l7$r3c$1 digitaldaemon.com...
 "C" <C_member pathlink.com> wrote in message
 news:c37jjq$1fg6$1 digitaldaemon.com...
 It took me a day to figure out that to use modules I had to specify the

 the compile command.  I just misunderstood the way the import keyword

 thought it was like #include and the compiler would chain the files


 it
 compiled.  Maybe I'm just stupid, but shouldn't that be documented

 would have no problem with doing it myself, but how do I get it


 on the
 D site?

I remember when I first started learning Java, I could not figure out how

 make the
 packages because there was nothing on the internet about it.
 It must have been overlooked, which is surprising, considering how very
 important
 it is.

 If you document it, I would definately read it!

And we'll put in in the first issue of TDJ, whenever that is ... ;)
Mar 17 2004
prev sibling parent reply Andrew Edwards <remove_ridimz remove_yahoo.com> writes:
On Tue, 16 Mar 2004 19:12:58 +0000 (UTC), C <C_member pathlink.com> wrote:

 It took me a day to figure out that to use modules I had to specify the 
 files in
 the compile command.  I just misunderstood the way the import keyword 
 worked.  I
 thought it was like #include and the compiler would chain the files 
 before it

With #include the entire content of the file specified between < and > will be inserted at the inclusion point, therefore the file does not need to be linked because the newly created object already has everything it needs. Not so with D. Importing only makes available "symbols" from the imported files. As such the file must be linked in order to resolve those symbols. It seems odd that we wouldn't be able to create a rule for the linker to automatically link all imported files. Along those same lines, shouldn't it be possible to specify libraries with which to link the current module? =========a.d=========== module a; linkwith [gdi32.lib, usr32.lib] // explicit linkage ... // do something important ======================= =========b.d=========== import a; // automatically linked upon import void main() { // do what b does best } ======================= typing the following: dmd b should expand to: dmd b a gdi32.lib usr32.lib I've only ever seen this (linkwith) used in assembly but I think it's a good feature to have.
 compiled.  Maybe I'm just stupid, but shouldn't that be documented 
 somewhere?  I
 would have no problem with doing it myself, but how do I get it 
 published on the
 D site?

 C

-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Mar 17 2004
parent reply C <dont respond.com> writes:
Hmm good thought , you could use Carlos' (or Lars ? sorry I forget ) =

dependecy checker to extract all the modules , and write a simple compil=
e =

driver to do that for you.

C

On Wed, 17 Mar 2004 22:35:07 -0500, Andrew Edwards =

<remove_ridimz remove_yahoo.com> wrote:

 On Tue, 16 Mar 2004 19:12:58 +0000 (UTC), C <C_member pathlink.com> =

 wrote:

 It took me a day to figure out that to use modules I had to specify t=


 files in
 the compile command.  I just misunderstood the way the import keyword=


 worked.  I
 thought it was like #include and the compiler would chain the files =


 before it

With #include the entire content of the file specified between < and >=

 will be inserted at the inclusion point, therefore the file does not =

 need to be linked because the newly created object already has =

 everything it needs. Not so with D. Importing only makes available =

 "symbols" from the imported files. As such the file must be linked in =

 order to resolve those symbols.

 It seems odd that we wouldn't be able to create a rule for the linker =

 automatically link all imported files. Along those same lines, shouldn=

 it be possible to specify libraries with which to link the current =

 module?

 =3D=3D=3D=3D=3D=3D=3D=3D=3Da.d=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 module a;
 linkwith [gdi32.lib, usr32.lib] // explicit linkage
 ... // do something important
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 =3D=3D=3D=3D=3D=3D=3D=3D=3Db.d=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 import a;  // automatically linked upon import
 void main()
 {
    // do what b does best
 }
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

 typing the following:

 dmd b

 should expand to:

 dmd b a gdi32.lib usr32.lib

 I've only ever seen this (linkwith) used in assembly but I think it's =

 good feature to have.

 compiled.  Maybe I'm just stupid, but shouldn't that be documented =


 somewhere?  I
 would have no problem with doing it myself, but how do I get it =


 published on the
 D site?

 C


-- = D Newsgroup.
Mar 18 2004
parent Carlos Santander B. <Carlos_member pathlink.com> writes:
In article <opr42r2pwtehmtou localhost>, C says...
Hmm good thought , you could use Carlos' (or Lars ? sorry I forget ) =

dependecy checker to extract all the modules , and write a simple compil=
e =

driver to do that for you.

C

Not mine: Lars'. However, digc can do that exactly. Maybe you'll want to check it. ------------------- Carlos Santander B.
Mar 18 2004