Module naming conventions
Bill Baxter
dnewsgroup at billbaxter.com
Mon Nov 19 08:04:38 PST 2007
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.
> Is this a big deal? Not really. Back to my example, if I'm porting to
> Linux, I see the problem from the compiler, then I fix my files (probably
> with a search/replace script), and I'm done. In the code, even on Windows,
> I'm not able to compile if I use the *class name* XMLFile, so the only part
> that doesn't work is the import.
--bb
More information about the Digitalmars-d
mailing list