Naming convention in Phobos
spir
denis.spir at gmail.com
Tue Mar 8 05:38:39 PST 2011
On 03/08/2011 11:00 AM, %u wrote:
>> I don't think I understand your reasoning. Enum members can't
> have names which are also keywords, hence enums should be
> capitalised? You could equally well use this argument for *all* D
> symbols...
>
> Yes, we could (and in fact, I'd advocate for a D version of C#'s @
> symbol for marking keywords as identifiers).
>
> However, the thing is that this happens _so_ often with enums that I
> think it's worth making it an exception. As soon as you start to
> write some sort of code that has to do anything remotely with
> programming, you can say something like:
>
> enum TypeCode
> {
> int,
> long,
> bool
> }
>
> as those are the most logical choices (and thinking around them is a
> bit difficult.) But you don't often really name a variable "int", so
> it's not so much as an issue with variables as with enums IMHO.
Fortunately, these are "very not" any kind of <<most logical choices>>. Neither
according to D's own naming convention, nore (imo) according to plain common
sense. I have the same kind of use case as you, apparently (including even a
'TypeCodes' enum!), and thank to D's very weird naming, /I/ can use sensible
names for enum members and various other symbol series, without resorting to a
kind of prefix code or such.
// same names as in the source language, thanx!
enum TypeCodes
{
Integer,
Real,
Text,
Logical,
Array,
...
}
Denis
--
_________________
vita es estrany
spir.wikidot.com
More information about the Digitalmars-d
mailing list