The Death of D1. (Was Tango vs Phobos)

superdan super at dan.org
Mon Aug 25 17:56:02 PDT 2008


Robert Fraser Wrote:

> superdan wrote:
> > it's a big issue to me just in the opposite direction. the c enum is brain damaged. even dennis ritchie so much as acknowledged it. (and he won't budge on the definition syntax. so i guess that does mean somethin'.) the c++ enum grew one lonely neuron. problem is we got just used to the wrong. we won't blink an eye at
> > 
> > enum { a = 1, b = 2 };
> > 
> > but we get pissed at
> > 
> > enum { a = 1.1, b = 2.5 };
> 
> I see the first as a problem, too. An enum is an _enumeration_.

yeah. an enumerated type to be pedantic. as in, let me enumerate some stuff. i don't see an integer following from that.

> It 
> should not be abused for bitfields, masks, constants or anything else. 

that's not an abuse. it's just use.

let me enumerate some math constants.

enum math_constants
{
    pi = 3.14,
    e = 2.71,
    avocado = 6.023e-23,
}

there was no abuse, your honor.

> Look at how it's used in Java/C# (ignoring the fact that Java's enum is 
> actually syntactic sugar for a class...):
> 
> - Only named enums are supported (otherwise, what are you enumerating?)

i am enumerating symbolic constants that logically belong together but don't have the same type.

> - They can't be used as bitfields/masks (constants can be used for this 
> purpose)

but enums are constants. so it looks like those doods got it all wrong because they have two concepts for the same thing.

> - You can't define them as arbitrary values.

how do you mean that. must pi be 10./3. or what.

> In D, it's all water under the bridge and it's just a keyword; it 
> doesn't matter that much. That being said, it's still a bad selection of 
> keyword IMO and there's no argument that's going to convince me that 
> `enum string CRLF = "\r\n";` is somehow an _enumeration_.

no but if you put it like this maybe it changes your perspective.

enum line_terminator
{
    crlf = "\r\n",
    cr = "\r",
    lf = "\n",
    lfcr = "\n\r"
}

eh.



More information about the Digitalmars-d mailing list