Forums

Capitization of enums values.

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

Capitization of enums values.

Postby nevdelap » Wed Jul 07, 2010 8:11 pm

Currently enums values don't have to begin with a capital. Namespaces, Classes, members, Enums names, etc must have the correct casing to avoid collisions, and Enum values wont collide with anything because they are in the scope of their enums name, but I think for...

1/ ensuring that it doesn't look like a shared member access, and
2/ enforcing consistency in naming

...they should be required to start with a capital, and since they are capitalized for use from other languages anyway, and stringified that way, they might as well be inside Cobra.

Currently Xxxx.yyyy could be an enum Xxxx with value yyyy, or it could be a class Xxxx with a shared member yyyy.
call me Nev.
nevdelap
 
Posts: 61
Location: Buenos Aires

Re: Capitization of enums values.

Postby Charles » Wed Jul 07, 2010 8:43 pm

nevdelap wrote:Currently Xxxx.yyyy could be an enum Xxxx with value yyyy, or it could be a class Xxxx with a shared member yyyy.

Yeah, but is that a bad thing? You could change one to the other and not have to edit your code. In fact, I was thinking about this when I allowed the lower case.

But I do hear your other points. And this is different than other declarations which dictate lower or upper. Another interesting idea, if capitalization is required, is to allow a bare enum value where one is expected:
if color == Red, print 'Stop!'

Any opinions from anyone else on requiring enum members to be capped? If we made that change, a -legacy-lower-enum-members option would be provided for existing code bases.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 78 guests