Module naming conventions

Steven Schveighoffer schveiguy at yahoo.com
Mon Nov 19 09:14:12 PST 2007


"Bill Baxter" wrote
> Steven Schveighoffer wrote:
>> "Bill Baxter" wrote
>>>> *) Easy-to-remember rule ("just use lowercase") prevents naming errors
>>>> slipping through the cracks on case-agnostic Windows.
>>> I've already said that I don't understand why this is a big deal , but 
>>> it was the the reason brought up by Walter.  (And my paraphrasing above 
>>> is not exactly what he said, but the only way I could make any kind of 
>>> logical sense out of it.)
>>
>> Here is why it's a deal (maybe not big, perhaps melon-sized):
>>
>> import tango.io.XmlFile
>> import tango.io.XMLFile
>>
>> (note these are not real modules)
>> [good explanation snipped]
>>
>> See, the problem with CamelCase is that it is sometimes subjective as to 
>> what part of the name should be capitalized.  This in itself isn't a huge 
>> problem except that on case-insensitive file systems, it is possible for 
>> the program to compile even though it shouldn't.
> >
>> If all module names are lower case, then this doesn't happen.  I know 
>> that I have to lower the case of everything, even acronyms.  There is no 
>> subjectivity.
>
> Yeh, if you convert to lower case improperly -- by adding extra 
> underscores (std.out_of_memory), or otherwise mangling incorrectly, 
> (std.regex, std.signals) -- then you will certainly get a compiler error.
>
> But I think Don's point is still valid.  Why doesn't the compiler check 
> the module declaration on Windows?  If you import tango.io.XMLFile and the 
> file the compiler gets from the OS has a module declaration saying "module 
> tango.io.XmlFile", then the compiler should barf on that.

I like this idea, but of course, there would have to be a requirement for 
module names to match the file names (which is not the case today).  I think 
this really is one of the parts of D that could use some improvement.

-Steve 





More information about the Digitalmars-d mailing list