Some Basic Questions
kirklin.mcdonald at gmail.com
Tue Aug 15 18:03:48 PDT 2006
> Kirk McDonald wrote:
>> Lutger wrote:
>>> Derek Parnell wrote:
>>>> No, I suggest you use a different naming convention. I would have your
>>>> class name start with a Capital letter and have your source file
>>>> name all
>>>> lowercase. And if you stick to one class per file, have your filename
>>>> different to the class by adding a suffix or prefix. For example,
>>>> module foo_m;
>>>> class Foo
>>> Can I ask you, what is your reason for naming a source file
>>> differently than the class? Does it have something to do with
>>> importing magic?
>> The name of the source file and the name of the class are completely
>> orthogonal. They have nothing to do with each other. They may be the
>> same or different as you wish. This is not Java: A source file can
>> contain zero classes or as many classes as you like.
>> That said, it is convention to name source files and modules
>> completely lower-case, and to start class names with a capital.
>> However, the language does not actually enforce either of these. If
>> nothing else, it is a /very bad/ idea to ever name the source file and
>> the module different things, even if they just differ in capitalization.
> I've noticed that unfortunatly, it can create quite a mess. I'm coming
> from C++, I don't know how Java handles it. Does it enforce it that hard?
Java mandates that each source file contain a single class with the same
name as the file. Java is more strictly object-oriented than C++ or D,
and can't have anything outside of a class.
> Maybe I've misunderstood it, I thought Derek Parnell meant the following:
> module foo.bar; // corresponds to foo/bar.d
> class Bar // don't do this, use a different name
> To avoid names such foo.bar.Bar, "if you stick to one class per file."
> This is something different than naming source file and module different.
Well, that's fine. I see nothing wrong with that.
Pyd: Wrapping Python with D
More information about the Digitalmars-d-learn