Page 1 of 1

904-warn-lowercase.cobra

PostPosted: Sun Jan 04, 2009 3:31 pm
by gauthier
I don't think namespace should be restricted to CamelCase,

some projects (log4net, lucene.net) and my own use lowercase for first prefix for namespacing.

Re: 904-warn-lowercase.cobra

PostPosted: Sun Jan 04, 2009 5:26 pm
by Charles
Why case a namespace in the same way as a local var? Also, do you desire to do the same with classes, interfaces, etc.?

Re: 904-warn-lowercase.cobra

PostPosted: Sun Jan 04, 2009 7:48 pm
by gauthier
you are kind of going with an open-ended question...

namespace are place holder with arbitrary name, having a warning is nice for consistency but I don't see the purpose of restricting how we name them as we do with interfaces (I*) with a compilation error

Re: 904-warn-lowercase.cobra

PostPosted: Mon Jan 05, 2009 3:47 am
by hopscc
For namespaces The unadorned (existing) form is giving a warning to try and lead you to cobra practice idiomatic naming.
You should be able to suppress that warning
with a trailing warning suppression comment - to indicate you know what you want ( e.g for accessing an existing dll)

Code: Select all
namespace fred   # .no-warnings.  ::: I know this is non cobra but needed this way


As an enhancement how about allowing a quoted string for the namespace - if quoted no warnings, no translations - use just as given ( with quotes removed)

Code: Select all
namespace "myNonCobraCompliantForm_Namespace"


I dont see any need for same with classes... Interfaces maybe if theres any C# libraries that use non camelcased naming....

Re: 904-warn-lowercase.cobra

PostPosted: Mon Jan 05, 2009 4:30 am
by jonathandavid
Chuck wrote:Why case a namespace in the same way as a local var? Also, do you desire to do the same with classes, interfaces, etc.?



I agree that consistency is a good thing, and that it makes more sense to have CamelCase namespace names (although, coming from a c++ background, I wouldn't roll my eyes if I see a lowercase namespace). However, as hopscc points out, Cobra should be respectful with other libraries that already use a lower case namespace. Suppose I'm working on some new modules for Lucene, and that I want to write them in Cobra. My code will not compile if I use the lucene namespace, but if I change it to Lucene then my code will not follow the conventions of the rest of the library. Consider how ugly this would be:

using Lucene; // For parts written in Cobra
using lucene; // For parts written in other .net languages

...


As for hopscc proposed solutions, I would rather suggest using a compiler flag : "Cobra --allow_lowercase_namespaces"

Re: 904-warn-lowercase.cobra

PostPosted: Mon Jan 05, 2009 4:37 am
by jonathandavid
BTW, I just checked and Lucene.net seems to use CamelCase namespaces:

https://svn.apache.org/repos/asf/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Index/CheckIndex.cs

But my previous post is still meaningful, just replace "lucene" by any other library that *actually* uses lowercase namespaces.

Re: 904-warn-lowercase.cobra

PostPosted: Sun Jan 11, 2009 7:36 pm
by Charles
hopscc wrote:For namespaces The unadorned (existing) form is giving a warning to try and lead you to cobra practice idiomatic naming.
You should be able to suppress that warning
with a trailing warning suppression comment - to indicate you know what you want ( e.g for accessing an existing dll)

Code: Select all
namespace fred   # .no-warnings.  ::: I know this is non cobra but needed this way


As an enhancement how about allowing a quoted string for the namespace - if quoted no warnings, no translations - use just as given ( with quotes removed)

Code: Select all
namespace "myNonCobraCompliantForm_Namespace"


I dont see any need for same with classes... Interfaces maybe if theres any C# libraries that use non camelcased naming....

Correct, you can use # .no-warnings.

Note that I relaxed the code regarding namespaces read from binary libraries (DLLs).

I don't like the quoted version because it implies to me that you could have spaces and other punctuation in the name. For example, that is the case in:
use FooBar from 'Foo Bar'

The warning for source-based lowercase namespace names will be left in place.

Btw I'm not opposed to giving our warnings id tags like CW1000, CW1001, etc and then allowing the user to disable specific warnings or have them reported as errors. But it's low on my list of priorities. Patches welcome.

Re: 904-warn-lowercase.cobra

PostPosted: Mon Jan 12, 2009 5:14 am
by hopscc
Well you can have spaces an other punctuation in filenames and dirs - Windows systems revel in it ('Program Files', 'Documents and Settings')

Does c# disallow making/using dll files with spaces in their names ?

(whether anyone should actually be encouraged to do so is another question)

quoting is a rather accepted way of specifying that we're stepping outside any existing conventions/ accepted idioms...
can always check quoted string for chars didnt like and emit a warning....

Re: 904-warn-lowercase.cobra

PostPosted: Mon Jan 12, 2009 2:13 pm
by Charles
# .no-warnings. already works.

Moving on.