Module naming conventions
Don Clugston
dac at nospam.com.au
Mon Nov 19 03:51:15 PST 2007
Walter Bright wrote:
> Bill Baxter wrote:
>> 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.
>
> This is not a big issue, but an irritation: sometimes, I see code
> developed on windows that names a file like: "Foo.h", but then
> #include's it with "foo.h". It all works fine until one tries to port
> the code to Linux. Worse, sometimes you'll see the reverse problem,
> where there's a Foo.c and a foo.c on Linux and you have to port it to
> windows.
> Having all file/module/package names in lower case is just a no-brainer
> way to avoid this issue.
>
> I'll also confess I just don't like filenames with caps, underscores, or
> special characters in them, nor do I like long filenames. I have some
> image programs that insist on writing out .JPG files, and if I forget to
> rename them to .jpg before ftp'ing them to the web server, they don't
> work. Using all lower case, simple filenames, minimizes problems moving
> the files between systems.
>
> I'm surprised nobody has asked why D doesn't simply enforce module names
> to be in all lower case <g>.
You could prohibit the use of module names differing only in case.
So that if one module has
import foo.bar;
and another has
import foo.Bar;
an error should be generated, even if the file(s) would be found on that OS.
The correct capitalisation should be obtained from the module statement.
(And even on Windows, you _could_ still check to see if the file case matches
the module statement).
More information about the Digitalmars-d
mailing list