Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88313 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18433 invoked from network); 18 Sep 2015 07:05:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Sep 2015 07:05:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=pajousek@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pajousek@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.179 as permitted sender) X-PHP-List-Original-Sender: pajousek@gmail.com X-Host-Fingerprint: 209.85.223.179 mail-io0-f179.google.com Received: from [209.85.223.179] ([209.85.223.179:33906] helo=mail-io0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F9/35-19961-AA7BBF55 for ; Fri, 18 Sep 2015 03:05:14 -0400 Received: by iofb144 with SMTP id b144so47564183iof.1 for ; Fri, 18 Sep 2015 00:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=mkiB974nQ6GDCgqagsVpb0sMcnEjJvdSukrOrdF3udg=; b=o/3nPw+rHCH7FiTFUGGSCOi4+5t8/qBmtHSKDsyKe8mjpC//2YDVkTvc92fdgyzpDr IdGen9NpCfrkI1X6Wc0hrLl+EBGp/y5eytzHu8mFdWJ8umMDBr4x7tJlnUBeuIDG9Ei1 h9tLlNyxDZoexUaFxrfQFFDZDxscSvZdlTgASd47mHaLBtUrQ5avWE3WfWu65EuGCN7I Vk/bYdpL5xjFAqbnMRCQBdMiQwxwy3Qvg7gU6706a6CB7fUbofvcAsXqrUKe4X3AmaB2 DEtm/hO/3A37dc0S8qe+Kdc7tGBne0rV/yIDjSEON0XJK6xRLanc/dkTW0zGl9wun9LF iZJA== MIME-Version: 1.0 X-Received: by 10.107.14.4 with SMTP id 4mr13077493ioo.169.1442559911995; Fri, 18 Sep 2015 00:05:11 -0700 (PDT) Received: by 10.107.189.132 with HTTP; Fri, 18 Sep 2015 00:05:11 -0700 (PDT) In-Reply-To: <55FB4791.4040807@gmail.com> References: <55FB4791.4040807@gmail.com> Date: Fri, 18 Sep 2015 09:05:11 +0200 Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Let's discuss enums! From: pajousek@gmail.com (=?UTF-8?Q?Pavel_Kou=C5=99il?=) On Fri, Sep 18, 2015 at 1:06 AM, Rowan Collins wr= ote: > Hi All, > > This has come up in passing a few times recently, but I'm not sure there'= s > ever been a dedicated discussion of it: would it be useful for PHP to hav= e a > built-in Enumeration type, and if so, how should it look? > > Many other languages have enum types, with varying functionality. The > central concept is always that there's some declared type with a bunch of > named constants, but beyond that there's a lot of variability: for starte= rs, > is it a type of object, a special way of naming integers, or an uncompara= ble > type more like booleans and nulls? > > > So, what are anyone's thoughts? Am I rambling on too much as usual? ;) > > Regards, > > -- > Rowan Collins > [IMSoP] > Hi, personally, I feel that you should be able to assign numeric value to each element (and have them implicit if not specified). This is imho better for serialization (but it can be done with names as well, yeah) - but more importantly, it also allows usage with bitwise operators, so you could use them as a "flags" (ie. $weekend =3D Days::SATURDAY | Days::SUNDAY). Regards Pavel Kou=C5=99il