Re: Let's discuss enums!

From: Date: Fri, 18 Sep 2015 21:56:14 +0000
Subject: Re: Let's discuss enums!
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-88362@lists.php.net to get a copy of this message
On 18 September 2015 01:49:35 BST, John Bafford <jbafford@zort.net> wrote: >an important benefit to providing a value for enums would be to allow for >changing or deprecating enums. So you might want to say something like: > >enum FormEvents { > PRE_SUBMIT, > PRE_BIND = PRE_SUBMIT, //deprecated name, provide mapping to new name >} I'm not sure whether I like it or not, but I note that Python allows this: every enum member must have a value, which can be of any type; if two members are given the same value, the later defined one is considered an alias of the first. There is a method to select an instance by value, which will always return the first member with that value, not the alias. The examples also include lots of ways of using the value with overloaded operators etc. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#88362) next »