On Tue, Mar 12, 2013 at 4:42 PM, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
Ethan Furman wrote:
There seems to be two basic camps: those that think an enum should be valueless ... and those for whom the integer is an integral part of the enumeration,
I think most people agree that both of these use cases are important. The split seems to be more between those that want to address them using separate types, and those that prefer a one-type-fits-all approach.
There's a third camp - those that think the stdlib should just provide a basic explicit "labelled value" building block, and let others worry about composing them into more complex APIs and custom data types with defined semantics. Layered APIs are a good thing, and in this case, the obvious layering option is to separate out the "labelling" part which is broadly useful for debugging purposes from the "group of related values" part which is used as a tool to help ensure program correctness by triggering errors at the point of the undefined operation rather than allowing nonsensical results based on an underlying data type like int or str. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia