Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57966 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51547 invoked from network); 22 Feb 2012 22:13:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Feb 2012 22:13:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:61162] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/70-46696-188654F4 for ; Wed, 22 Feb 2012 17:13:22 -0500 Received: by wibhm4 with SMTP id hm4so421562wib.29 for ; Wed, 22 Feb 2012 14:13:19 -0800 (PST) Received-SPF: pass (google.com: domain of kris.craig@gmail.com designates 10.180.80.71 as permitted sender) client-ip=10.180.80.71; Authentication-Results: mr.google.com; spf=pass (google.com: domain of kris.craig@gmail.com designates 10.180.80.71 as permitted sender) smtp.mail=kris.craig@gmail.com; dkim=pass header.i=kris.craig@gmail.com Received: from mr.google.com ([10.180.80.71]) by 10.180.80.71 with SMTP id p7mr322007wix.10.1329948799552 (num_hops = 1); Wed, 22 Feb 2012 14:13:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=KIFUite5xxSANFbEOJYcEVAGRwBqWFpI4QFaOY2AiwU=; b=dI/3sFtG/sLdcdnylmxfisvlXG6oOr9cxC9Db551dYeQ4S5ffo0/lpUGyWSt1KnS67 dUdsmZQaYfwqbegIx0wRkMLV1Uu34z07Mvt9YoDsEIOYrrVh/wabv0zCyZd+HwO4iYxi ljq4EgZgO9pNSwRcOYxb2XxCDuYXSFXXkElrM= MIME-Version: 1.0 Received: by 10.180.80.71 with SMTP id p7mr261981wix.10.1329948799441; Wed, 22 Feb 2012 14:13:19 -0800 (PST) Received: by 10.223.75.146 with HTTP; Wed, 22 Feb 2012 14:13:19 -0800 (PST) In-Reply-To: <028001ccf1ab$0b200050$216000f0$@alliantinternet.com> References: <4F455C96.50706@gmail.com> <4F455E91.2060408@alliantinternet.com> <028001ccf1ab$0b200050$216000f0$@alliantinternet.com> Date: Wed, 22 Feb 2012 14:13:19 -0800 Message-ID: To: Dmitri Snytkine Cc: Sebastian Krebs , PHP internals list Content-Type: multipart/alternative; boundary=f46d0442887cc29b6904b994d592 Subject: Re: [PHP-DEV] [RFC] Enum proposal (yet another) From: kris.craig@gmail.com (Kris Craig) --f46d0442887cc29b6904b994d592 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable While I'm a huge fan of Github, why did you decide to host your RFC there instead of on the PHP wiki? I realize there's an older proposal there right now, but that's from 2010 and seems to be dead in the water. Even if yours is just a draft, the wiki is designed to be able to accommodate progressive revisions. I only mention this because I think it definitely helps to have one central place where all the RFCs can be looked at, including the draft ones. At very least, could you add a link to your RFC on the wiki page? I'd also like to throw another idea out there: Should we consider amending the RFC procedures to allow for expiration of old RFCs that have never been moved to the voting stage? I was wondering because that older enum RFC is still "Under Discussion" and last modified nearly a year ago; actually proposed nearly 2 years ago. It seems to have been abandoned so I'm just curious if maybe we should have some process in place to categorize that. Regarding this particular RFC, personally I've never seen the need to use enums, but it certainly does sound like something that would add convenience and make that one less feature other languages have that PHP doesn't. So I don't personally have any objection so long as the implementation is solid. --Kris On Wed, Feb 22, 2012 at 1:43 PM, Dmitri Snytkine < dsnytkine@ultralogistics.com> wrote: > > For those who keep saying "but this can already be done in php", here is = a > pretty good article. > Long time ago enums were not available in Java also, so this article > explains that yes, thigs can technically could be done before the enum, a= nd > why certain things are better with enums. > > > http://javarevisited.blogspot.com/2011/08/enum-in-java-example-tutorial.h= tml > > I think enums will be beneficial to php, but will add one more features > that > people not familiar with it will have to learn about. > > Dmitri Snytkine > Web Developer > Ultra Logistics, Inc. > Phone: (888) 220-4640 x 2097 > Fax: (888) 795-6642 > E-Mail: dsnytkine@ultralogistics.com > Web: www.ultralogistics.com > > "A Top 100 Logistics I.T. Provider in 2011" > > > -----Original Message----- > From: Sebastian Krebs [mailto:krebs.seb@googlemail.com] > Sent: Wednesday, February 22, 2012 4:31 PM > To: PHP internals list > Subject: Re: [PHP-DEV] [RFC] Enum proposal (yet another) > > Am 22.02.2012 22:22, schrieb =C1ngel Gonz=E1lez: > > On 22/02/12 09:37, Sebastian Krebs wrote: > >> class MyEnum { > >> const FOO =3D 'foo'; > >> const BAR =3D 'bar'; > >> private $value; > >> public function __construct ($value) { > >> if (!in_array($value, array(self::FOO, self::BAR)) throw new > >> UnexpectedValueException; > >> $this->value =3D $value; > >> } > >> public function __toString () { return $this->value; } > >> } > >> > >> > >> function doSomething (MyEnum $foo) { /* code */ } > >> > >> > >> What I wanted to say: I don't see, what is not possible already? > > > > I want to call it doSomething(FOO) or doSomething(MyEnum::FOO), > > not doSomething(new MyEnum(MyEnum::FOO)); > > > > > // The class file > class MyEnum { > public static $FOO; > public static $BAR; > const FOO =3D 'foo'; > const BAR =3D 'bar'; > private $value; > public function __construct ($value) { > if (!in_array($value, array(self::FOO, self::BAR)) throw new > UnexpectedValueException; > $this->value =3D $value; > } > public function __toString () { return $this->value; } > } > /* static code block */ { > // As long as PHP doesn't support "constant references" (;)) > // (--> constants with objects or arrays) > MyEnum::$FOO =3D new MyEnum(MyEnum::FOO); > MyEnum::$BAR =3D new MyEnum(MyEnum::BAR); > } > // End class file > > // Somewhere deep within some other code > doSomething (MyEnum::$FOO); > > > > > > However, I can't see, what is the big thing, that isn't currently not > possible (except any "I want"-argumentation :X) > > Sidenote, according your examples above on how you want call functions: > Considered using normal constants? > > > > > > +1 for adding enums (although I'm open to variations from that exact > > proposal). > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --f46d0442887cc29b6904b994d592--