Forums

904-warn-lowercase.cobra

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

904-warn-lowercase.cobra

Postby gauthier » Sun Jan 04, 2009 3:31 pm

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.
gauthier
 
Posts: 116

Re: 904-warn-lowercase.cobra

Postby Charles » Sun Jan 04, 2009 5:26 pm

Why case a namespace in the same way as a local var? Also, do you desire to do the same with classes, interfaces, etc.?
Charles
 
Posts: 2510
Location: Los Angeles, CA

Re: 904-warn-lowercase.cobra

Postby gauthier » Sun Jan 04, 2009 7:48 pm

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
gauthier
 
Posts: 116

Re: 904-warn-lowercase.cobra

Postby hopscc » Mon Jan 05, 2009 3:47 am

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....
hopscc
 
Posts: 631
Location: New Plymouth, Taranaki, New Zealand

Re: 904-warn-lowercase.cobra

Postby jonathandavid » Mon Jan 05, 2009 4:30 am

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"
jonathandavid
 
Posts: 159

Re: 904-warn-lowercase.cobra

Postby jonathandavid » Mon Jan 05, 2009 4:37 am

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.
jonathandavid
 
Posts: 159

Re: 904-warn-lowercase.cobra

Postby Charles » Sun Jan 11, 2009 7:36 pm

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.
Charles
 
Posts: 2510
Location: Los Angeles, CA

Re: 904-warn-lowercase.cobra

Postby hopscc » Mon Jan 12, 2009 5:14 am

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....
hopscc
 
Posts: 631
Location: New Plymouth, Taranaki, New Zealand

Re: 904-warn-lowercase.cobra

Postby Charles » Mon Jan 12, 2009 2:13 pm

# .no-warnings. already works.

Moving on.
Charles
 
Posts: 2510
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 9 guests

cron