forked from xp-framework/xp-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
core.enum
Alex Kiesel edited this page May 26, 2012
·
6 revisions
Often there is the necessity to define functionality based on a set of values. If you have experience in C, you may have seen typedef enum { WHITE, BLACK, YELLOW } color_t; before. In PHP, one could write something like define('WHITE', 0); and define('BLACK', 1); which is pretty much what the C version does. The problem with these approaches are that they are not type-safe, and functionality needs to be attached by using switch or if-else cascades.
Here's some more information on enums in the XP framework:
- [entry://222 Enum usecases: Replace switch/case blocks]
- [entry://207 Enum usecases: Profiling]
- [entry://199 EASC and enum types]
Enums were first introduced in July 2007 within [rfc://0132 RFC 0132].