[Issue 9065] Please consider adding these std.traits

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 28 06:59:37 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9065



--- Comment #49 from Manu <turkeyman at gmail.com> 2012-11-28 06:59:34 PST ---
(In reply to comment #48)
> I believe the similarity you've listed is false. An enumerated type must be
> integral (it must be countable!) A manifest constant, however, can be anything
> - a struct literal, for example.

... really? But D supports typing enums:

enum E : string
{
  X = "hello",
  Y = "world"
}

I tried:

enum E : string
{
  X = "hello",
  Y
}

Sure, this would normally try and increment by one, but since it's not integral
I got this error: incompatible types for (("hello") + (1)): 'S' and 'int'

Makes perfect sense to me, apparently you just lose the auto-increment
behaviour if the enums are not an integeral type? (although the error message
could be clearer)

So perhaps you mean, "must be integral if you want auto-increment behaviour"?
Often enough you don't even want auto-increment, you want a collection of
meaningful pre-defined values, I think that's just as good a definition of the
term 'enumeration', auto-increment is not fundamental to this enumerated type
concept in my mind. In fact, I think I might even use all-explicit values more
often than auto-incremented ones in my code.


> I think what has happened is that C had a very sloppy enum design, where it
> mixed integral manifest constants with enumerated types. Instead of tightening
> up 'enum', we used the existing sloppiness as an excuse to make it worse.

Worse? It's perfect... >_<

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list