Module naming conventions

Bill Baxter dnewsgroup at billbaxter.com
Mon Nov 19 06:23:15 PST 2007


Christopher Wright wrote:
> Bill Baxter wrote:
>> Stepping aside from the crazy Phango thread, I'd like to see if we can
>> we try to put together a list of actual arguments for and against
>> different module naming conventions.  No editorial comments by me here.
>>
>> Is this list complete?
>>
>> Convention LC: All package module names are lower case all the time.
>> Example:   import foo.bar.baz;
>> Pros:
>> *) Long established convention (~10 years) used by Phobos
>>
>> *) Differentiates module names from class names.
>>    Like class "Stream" in module "std.stream
>>
>> *) Related: prevents redundancy in fully qualified names
>> (std.stream.Stream, not std.Stream.Stream)
>>
>> *) Easy-to-remember rule ("just use lowercase") prevents naming errors
>> slipping through the cracks on case-agnostic Windows.
>>
>>
>>
>> Convention CC: All package names are lowercase, but module names are
>> upper case, and match name of contained class where applicable.
>>
>> *) Established convention (~4 years) used by Tango
>>
>> *) Differentiates package names from module names to prevent naming
>> clashes. (Lets you have file "OpenGL.d" in same directory where there's
>> an "opengl" package directory)
>>
>> *) Makes it easy to remember name of module where class FooBar is
>> defined (it'll be in FooBar.d)
>>
>> *) Fine granularity approaching one-module-per-class means D's linker 
>> will generate smaller executables.
> 
> I thought there was overhead for each module, and a good linker 
> shouldn't lump in everything from every referenced module. So this point 
> is not clear to me.
> 
> Also, there are two orthogonal issues here: having small modules and 
> having CamelCase modules. Can we discuss them separately?

Agreed.  I'm realizing that it was wrong to ignore the distinction.

I think ultimately it may comes down to lowercase making the most sense 
for flat hierarchies with big modules, and camel case making the most 
sense for the hierarchies with many small modules.  So in that sense 
both Phobos and Tango use the convention that works best with the 
overall library organization.

--bb



More information about the Digitalmars-d mailing list