Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57947 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48418 invoked from network); 22 Feb 2012 14:15:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Feb 2012 14:15:31 -0000 Received: from [127.0.0.1] ([127.0.0.1:29047]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 51/76-09421-388F44F4 for ; Wed, 22 Feb 2012 09:15:31 -0500 Authentication-Results: pb1.pair.com smtp.mail=eitan@mosenkis.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=eitan@mosenkis.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain mosenkis.net designates 209.85.213.42 as permitted sender) X-PHP-List-Original-Sender: eitan@mosenkis.net X-Host-Fingerprint: 209.85.213.42 mail-yw0-f42.google.com Received: from [209.85.213.42] ([209.85.213.42:47621] helo=mail-yw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BB/F5-09421-7D4F44F4 for ; Wed, 22 Feb 2012 08:59:52 -0500 Received: by yhfq11 with SMTP id q11so31540yhf.29 for ; Wed, 22 Feb 2012 05:59:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mosenkis.net; s=google; h=received-spf:dkim-signature:mime-version:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=cBTdKBKWorxgPVup68cDaqyR9DPaQ+F/VlcZsskozYI=; b=O5BLPiLslx7pZmwztUD4NMpyidFNGno4YdnQjc99hdmrzHsAcUggXFTi2UHWG3PtVW iw91t5OBjNoHH067sxa/cPMefq0uHbwx8iR3lyxsH8U2qA2YLeucBYFnlPykFNaQTSaI Jv75tDo4CjQSw3gGsfjIrAViLIUABILKbuY9U= Received: by 10.100.243.16 with SMTP id q16mr4851188anh.31.1329919189303; Wed, 22 Feb 2012 05:59:49 -0800 (PST) Received: from mail-yx0-f170.google.com (mail-yx0-f170.google.com [209.85.213.170]) by mx.google.com with ESMTPS id b17sm19209224anc.0.2012.02.22.05.59.48 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 22 Feb 2012 05:59:48 -0800 (PST) Received: by yenm5 with SMTP id m5so27889yen.29 for ; Wed, 22 Feb 2012 05:59:47 -0800 (PST) Received-SPF: pass (google.com: domain of eitan@mosenkis.net designates 10.101.5.24 as permitted sender) client-ip=10.101.5.24; Received: from mr.google.com ([10.101.5.24]) by 10.101.5.24 with SMTP id h24mr2980426ani.45.1329919187894 (num_hops = 1); Wed, 22 Feb 2012 05:59:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mosenkis.net; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=cBTdKBKWorxgPVup68cDaqyR9DPaQ+F/VlcZsskozYI=; b=PhKamw0DyjkOsG42Kchf0a+8WIujJ2/lzTYIgqx4Q18QaooShUJjfGeAxvzX97az4y YrV18uC22nHfqTfPHrXldjf9Lp68mPfBa2A+dk17en/4S9/oNE0B1XFAplBJpYQ4UbV+ musos3Yh3hG6dfZaeg/5L82Ek7I9NG4FgExAA= Received: by 10.101.5.24 with SMTP id h24mr2408684ani.45.1329919170788; Wed, 22 Feb 2012 05:59:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.147.34.1 with HTTP; Wed, 22 Feb 2012 05:57:58 -0800 (PST) In-Reply-To: References: Date: Wed, 22 Feb 2012 08:57:58 -0500 Message-ID: To: Samuel Deal Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQmNK8wvTatsdgNUh9jYkI5IRQwtynz4fsNcqs2cxhuWAkqytFr96BjmXITmMArk3U2h+Hwg Subject: Re: [PHP-DEV] [RFC] Enum proposal (yet another) From: eitan@mosenkis.net (Eitan Mosenkis) I think that your proposal looks good, but I'd like to suggest a few changes. First of all, I'd like to see the association with integers removed. An enum instance shouldn't just be a name for an integer, it should be more like a singleton instance of a special kind of class that can only ever have a predefined set of named instances. There should be no value associated with it. Secondly, there already exists the capacity for arbitrary classes to be used in foreach and count you just have to implement Iterator and Countable. Other interfaces that all enums might want to implement automatically are ArrayAccess and Serializable. This would just require the enum itself to be an object (maybe of type enum or something) such that it can implement the relevant methods. http://www.php.net/manual/en/class.iterator.php http://php.net/manual/en/class.countable.php On Tue, Feb 21, 2012 at 11:45 PM, Samuel Deal wrote= : > Hi all, > > I really missed enums in PHP, > So after reading I tryed to synthetise the various views. > > You can find a draft here : > https://github.com/SamNrique/php-src/wiki/RFC-draft > (I can't write on the wiki, and perhaps it's better to finish the > discussion first) > > There's an implementation with this draft. > I'd love to have feedbacks because it's my first php-core hack. > > Thanks > -- > Samuel D=C3=A9al > samuel.deal@gmail.com