Modules vs Packages

Bill Baxter dnewsgroup at billbaxter.com
Sat Sep 8 08:14:01 PDT 2007


Jarrett Billingsley wrote:
> "Giuseppe Bilotta" <giuseppe.bilotta at gmail.com> wrote in message 
> news:fbtpp1$2k8t$1 at digitalmars.com...
> 
>> I see no reason why we couldn't have
>>
>> package.d
>> package/module1.d
>> package/module2.d
>>
> 
> This has been brought up so many times.. I think Walter needs to put an 
> explanation of this on the modules page.
> 
> I don't see the reason for it either.  I think other people have explained 
> it as something along the lines of "packages aren't the same as modules, so 
> you can't have one name map to two things".  I don't buy that.  I don't see 
> how packages are any different from modules.  They're both just namespaces. 
> That's how they work in my scripting language: packages == modules, and you 
> can have packages and modules with the same name.
> 
> Until (if) this changes, the most common way to do what you want to do in D 
> is to have a "relcomp.all" module which imports everything else. 

And I recommend .api instead of .all if you don't actually import /all/ 
the modules.  Or even if you do.  Or I suppose you could have both - 
.api being lean and mean API, and .all being the moral equivalent of 
#include <windows.h>.

(This .api convention comes from python, btw.
see e.g. http://neuroimaging.scipy.org/neuroimaging/ni/ticket/86)

--bb



More information about the Digitalmars-d mailing list