www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - import/modules

reply marksibly <blitzmunter gmail.com> writes:
Hi,

D newbie here with a few import/module related questions.

I have a test project with the following dir/file layout:

c:\test.d
c:\testmod\test2.d

The modules reference each other via imports (very nice!) and it all
compiles fine as long as I specify both modules on the dmd command
line, eg:

c:\> dmd test.d testmod\test2.d

But I can't get '-I' to do this for me, eg:

c:\> dmd -Ic:\ test.d

...doesn't work - can't find the second module.

What am I doing wrong? Or is this just the way it works? If so, what
does -I actually do?

I also notice that you seem to be able to call packages/modules
anything you want!

The docs state that package names=dirs and module names=files, but
you can apparently use anything you want for either, as long as the
module decl matches the import.

Not a biggy, but then what exactly are packages for?

Bye!
Mark

ps: the samples in the windows release don't work - they're looking
for a dmd/bin dir, but there's only dmd/windows. Tried copying
bin & lib dirs in windows up a level but no luck.
Jun 24 2010
next sibling parent bearophile <bearophileHUGS lycos.com> writes:
marksibly:
 D newbie here with a few import/module related questions.

Welcome here :-) Are your questions relative to the latest D2 version or D1? Keep in mind that D1 and D2 module system has several bugs.
 ...doesn't work - can't find the second module.
 What am I doing wrong? Or is this just the way it works?

Even if it sounds strange, this is the way it is designed to work. For reasons that I don't fully like DMD is not like Java, it is not able to look by itself for the modules. So you need an external program to do it, there are several.
 If so, what does -I actually do?

I don't know that option in D2.
 I also notice that you seem to be able to call packages/modules
 anything you want!
 The docs state that package names=dirs and module names=files, but
 you can apparently use anything you want for either, as long as the
 module decl matches the import.

The main D designer (Walter) seems to like the module name situation like this, even if it looks wrong to me, and I have filed a bug report on it. If you subscribe to Bugzilla you can give one vote to this bug report: http://d.puremagic.com/issues/show_bug.cgi?id=3972
 Not a biggy, but then what exactly are packages for?

I think they currently buggy. As in Python they are meant as a way to group code at a level higher than the module one.
 ps: the samples in the windows release don't work

They are probably not updated. Probably some one will work on them in less than few weeks. Keep in mind that the D2 compiler has just come out of Alpha state and the number of D devs is quite small. Bye, bearophile
Jun 24 2010
prev sibling parent BCS <none anon.com> writes:
Hello marksibly,

BTW, whatever client you are using is generating text that, for me, renders 
without spaces. I suspect a code page/UTF/whatever issue.

 Hi,
 
 Dnewbieherewithafewimport/modulerelatedquestions.
 
 Ihaveatestprojectwiththefollowingdir/filelayout:
 
 c:\test.d
 c:\testmod\test2.d
 Themodulesreferenceeachotherviaimports(very nice!)anditall
 compilesfineaslongasIspecifybothmodulesonthedmdcommand line,eg:
 
 c:\> dmdtest.dtestmod\test2.d
 
 ButIcan'tget'-I'todothisforme,eg:
 
 c:\> dmd-Ic:\test.d
 
 ...doesn'twork-can'tfindthesecondmodule.
 
 WhatamIdoingwrong?Oristhisjust thewayitworks? Ifso,what
 does-Iactuallydo?
 
 Ialsonoticethatyouseemtobeabletocallpackages/modules anythingyouwant!
 
 Thedocsstatethatpackagenames=dirsandmodulenames=files,but
 youcanapparentlyuseanythingyouwantforeither,aslongasthe
 moduledeclmatchestheimport.
 
 Not a biggy, but then what exactly are packages for?
 
 Bye!
 Mark
 ps:thesamplesinthewindowsreleasedon'twork-they'relooking
 foradmd/bindir,butthere'sonlydmd/windows.Triedcopying bin &
 libdirsinwindowsupalevelbutno luck.
 

... <IXOYE><
Jun 26 2010