Phobos packages a bit confusing

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Nov 29 12:03:03 PST 2009


retard wrote:
> Hi
> 
> after using D1 and Tango for couple of years we decided to experiment 
> with D2 and Phobos in a small scale project. For some reason the mostly 
> flat package hierarchy seemed rather confusing.
> 
> For instance, it took two of us 15 minutes to build a program that reads 
> a line from user, converts the string to a natural number, adds one, and 
> finally prints it to the screen. Entities like 'stdin' seem to have no 
> documentation at all. What should I import to get it, what interfaces 
> does it implement etc.
> 
> When writing this, I already forgot what package contained the to! 
> template. My intuition says it should be in
>  * std.stdint [int related operations]
>  * std.format [number formats?]
>  * std.typecons [we're constructing a int from a string]
>  * std.string [the input was a string, maybe toInt is a string operation]
>  * std.numeric [it's a numeric operation, isn't it]
> 
> I admit using higher level languages has made major damage to my brain 
> ("500.1".toInt anyone?), but still using Tango, Java, or C# seems rather 
> intuitive, but in Phobos the set of packages and their contents feels 
> more or less arbitrary. Is there anything that can be done?

These are great points. I personally consider import files a necessary 
evil. There are a couple of things that make me hopeful about 
simplifying the situation:

a) D parses fast enough to allow importing extensive modules;

b) The "no-hijack" approach allows liberal importing of modules without 
fear of serious name clashes.

Walter and I discussed quite a few times the possibility of defining 
std.all that publically imports all of std. My experiments show that a 
short script importing std.all will compile slower, but not too slow, 
compared to a script that only import a few modules.

One other possibility would be to define some generic modules that group 
together useful lower-level modules. The question is of course how to 
name those aggregation modules (std.common?) and what they should include.

Some PR or tips on how to search the documentation may also be helpful. 
If you navigate to Phobos' homepage 
http://digitalmars.com/d/2.0/phobos/phobos.html and then enter

conversion

in the search box, std.conv comes up first. Also, the same module comes 
up first if you search this with google:

d programming language conversion

It would be great to improve D and Phobos accessibility for first-time 
users.

(To my personal satisfaction, searching google for

std::algorithm

puts D's std.algorithm in the third or fifth position (depending how you 
count), after the obligatory C++ reference sites.)


Andrei



More information about the Digitalmars-d mailing list