Enums/flags as objects?
| From: | Andrei Zmievski | Date: | Tue, 10 Aug 2004 06:27:50 +0000 |
| Subject: | Enums/flags as objects? | ||
| Groups: | php.gtk.dev | ||
| Request: | Send a blank email to php-gtk-dev+get-703@lists.php.net to get a copy of this message | ||
I have just discovered that it is possible to register object constants.
This raises interesting possibilities. In PHP-GTK 1, the various
enums/flags are simply integers, so it is hard sometimes to figure out
what 0 or 2 means when trying to debug the applications. With the object
approach, each enum could be an object wrapper, that knows how to
compare itself, output its string representation, etc. The downside is
that objects take more memory, obviously.
Do you think wrapping enums/flags as objects has advantages? PyGtk 2.3.x
seems to do it this way.
-Andrei
For society, it's probably a good thing that engineers value function over
appearance. For example, you wouldn't want engineers to build nuclear power
plants that only _look_ like they would keep all the radiation inside.
(Scott Adams - The Dilbert principle)