Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88299 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82430 invoked from network); 17 Sep 2015 23:56:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Sep 2015 23:56:51 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.180 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.180 mail-wi0-f180.google.com Received: from [209.85.212.180] ([209.85.212.180:32905] helo=mail-wi0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/42-05737-3435BF55 for ; Thu, 17 Sep 2015 19:56:51 -0400 Received: by wiclk2 with SMTP id lk2so43745135wic.0 for ; Thu, 17 Sep 2015 16:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:from:to:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=kpmPEdDazw1fEVL2b8F2hV3j+y0naPV74QgmiQ3bcL0=; b=Pj33ISezxWWv10yEPEEwjfu7Tu0N+1gHaSDBK82Nk1SyB+iH2P7lljs7Jx+S/w77bg P9G92fNFO7MyC55lGXSsASKqNbi9pS8/xzKURUExefKq9vbE1p/yWajV+WpOZbPPq7ft 1Tu1Uk7M1+D2xjRdH0W2Kci/0F92yNhlUWqH1UPomtNBSskDJSE0A5u8jEyQbekU+HP8 nYp/XJWhjMftpm71cZsseYAfl8CNdc51tQ19EqKKejM4nKSdAJcptmKURVz404ub+gn1 ruXJQwHgiH3wFmUu8vDZcemFgZkubXXDhLWeyk/HhoLU4vLg08k86iPo8UvwLoTvagRp Wiog== X-Received: by 10.194.171.3 with SMTP id aq3mr3334558wjc.54.1442534208863; Thu, 17 Sep 2015 16:56:48 -0700 (PDT) Received: from [192.168.0.5] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by smtp.googlemail.com with ESMTPSA id n2sm12539476wib.18.2015.09.17.16.56.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2015 16:56:48 -0700 (PDT) References: <55FB4791.4040807@gmail.com> To: PHP internals Message-ID: <55FB533F.7080301@gmail.com> Date: Fri, 18 Sep 2015 00:56:47 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Let's discuss enums! From: rowan.collins@gmail.com (Rowan Collins) On 18/09/2015 00:16, Marcio Almada wrote: > A kitten is working on thathttps://wiki.php.net/rfc/enum. Many points > on the linked RFC are compatible to the points you raised so it might > be worth reading before even starting any new proposal. Aha, I hadn't seen that, should have thought to search the wiki. Still, interesting that we seems to mostly agree on the key decisions, although I've gone into more detail about things that he's left as Future Scope, which is fair enough. The main thing I'd change if I was writing it is the implicit "ordinal" property; I don't really see the point of insisting that the order I write "Red, Green, Blue" has some meaning. On the other hand, I'd give much more prominence to the name, e.g. by making values() return an associative array. You're much more likely to want to say "the value whose name is 'RED'" than "the value I defined first in the list", IMHO. If you have some kind of initialiser syntax for the values - with or without a constructor - you get to have ordinals or explicit values (like the Flags example) if you want them, and just names if not: enum RenewalAction{ Deny( 0 ), Approve( 1 ); public $ordinal; } enum Flags{ a (1 << 0), b( 1 << 1), c( 1 << 2), d( 1 << 3 ); public $value; } enum PimaryColours { RED, GREEN, BLUE } Regards, -- Rowan Collins [IMSoP]