2011/6/3 John Crenshaw <johncrens...@priacta.com>

> As much as I used enums in C++, I'm not sure that this is really the right
> tool here, and it often introduces more problems than it solves. Specific
> concerns that come to mind:
>
> 1. In C++ this often led to nasty needs such as a "LOG_LEVEL_COUNT" entry
> at the end of the list of enums.
> 2. Sometimes devs want to add items in the middle of the list for code
> organization purposes. This silently changes the values of the other
> constants and it isn't clear when that will or won't break stuff.
> 3. Better than half the time, enums seem to be a series of bit flags, not
> sequential numbers (in this case enum offers NO value over the current const
> lists).
> 4. The greatest value of enums in C++ is actually related to typesafety.
> Admittedly, this was sometimes more of a frustration than a help, but that
> was really just an implementation issue, not an inherent problem with enums
> and typesafety.
> 5. There is no clear path for extending the enums through inheritance.
>
> Allowing enums to be (optionally) named would open a clear path to address
> counts and hinting, but still doesn't address the problems inherent in
> automatic numbering, and would complicate the inheritance question.
>
> IMHO this should wait until we can address some of these items. Otherwise
> the feature is just a halfbaked not-so-short shorthand for constants.
>
> John Crenshaw
> Priacta, Inc.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

1. I'm not so sure what you mean with that statement
2. A very strong argument for using the name of the constant as the default
value
3 and 4: The way I see it, type safety is the *only* valid argument for
proposing enums
5: I have never felt the need for inheritance in enums. Do you have a use
case for that?

I also think that enums should always be named.

--
Dennis Haarbrink

Reply via email to