Naming things in Phobos - std.algorithm and writefln

Don nospam at nospam.com
Wed Aug 5 05:15:49 PDT 2009


Michel Fortin wrote:
> In std.algorithm, wouldn't it be clearer if "splitter" was called 
> "splitLazily" or "splitLazy"? "splitter" is a noun, but as a function 
> shouldn't it be a verb. "makeSplitter" or "toSplitter" perhaps?
> 
> And what about the "array" function? Wouldn't it be clearer if it was 
> "toArray" so we know we're preforming a convertion?
> 
> As you know, I tried to write some guidelines[1] for naming things in D. 
> Those guidelines looks well at first glance, but then you look at Phobos 
> and you see that half of it use some arbitrary naming rules. Take 
> "writefln" for instance: following my guidelines (as they are currently 
> written) it should be renamed to something like "writeFormattedLine".

There should be an exception for functions which are analogous to C 
functions and have well established names in C. (eg, printf). Probably 
for famous functions in other languages, too. writeln() comes from 
Pascal, analogy with printf gives us writefln(). So that one's OK.

> I could take a look at std.algorithm and other modules in Phobos to list 
> inconsistencies with the guidelines. From this we could make 
> improvements both to the guideline document and the API. But before 
> going too deep I think we should start with a few examples, such as 
> those above, and see what to do with them.
> 
> What does everyone thinks about all this?

Yes, this is great. A review process would be very valuable.
Please check the names in std.math. For the most part I have taken the 
names from the IEEE754-2008 standard, but please make suggestions. As we 
move towards finalizing D2.0, that module should be one of the first to 
have its interface frozen.



More information about the Digitalmars-d mailing list