Re: Let's discuss enums!

From: Date: Fri, 18 Sep 2015 14:23:35 +0000
Subject: Re: Let's discuss enums!
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-88326@lists.php.net to get a copy of this message
> Am 18.09.2015 um 10:42 schrieb Rowan Collins <rowan.collins@gmail.com>: > > On 18 September 2015 01:15:43 BST, Bob Weinand <bobwei9@hotmail.com> wrote: >> The reason it is not an associative array is that the names are not >> important. > ... >> You never should *rely* on the ordinal value of the enum for anything. > > I feel like I'm missing something here. In my mind, the only absolute universal about all > enum implementations is that you refer to values by constant names - e.g. Weekdays::SUNDAY. The name > 'SUNDAY' is as fundamental and unchanging as the name 'Weekdays'. > > We rely on names to reference classes and functions all the time, and to serialize properties > of an object; so what is it about enums that makes having an integer accessible so important? > > I note that Java does supply an ordinal(), but the docs say you should basically never use it. > > Regards, > -- > Rowan Collins > [IMSoP] Well, I think we should *either* have an ordinal *or* a name. But not both. Currently, after thinking about it, I'm in favor of just a name. And no ordinal. Having both is, I think, unnecessary. Bob

« previous php.internals (#88326) next »