Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112684 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 4522 invoked from network); 30 Dec 2020 20:47:21 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Dec 2020 20:47:21 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 55C0E1804CF for ; Wed, 30 Dec 2020 12:22:07 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 30 Dec 2020 12:22:06 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 23D5090A for ; Wed, 30 Dec 2020 15:22:05 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute4.internal (MEProxy); Wed, 30 Dec 2020 15:22:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=hEZQ7E pPi6P3c+CNbBE9BKkxNqXb1xlTAxoqjwj/QV8=; b=Lpu4ngWjR0kNT8aAcwXCSG Zozlsj1vibkK2aw2/PyJuMVAa0NcKyu4ThIFJRICK4NaCUbbrIlIsRqyL0+DrIjE ykKdr8LPkipGj9zVEvbyt+KDF6F3k+TkRDI82iGBrdiH9sgm2HTTAaVNeTQ8KvMK 2Y6Z73MR9q7nCx69w3pc6mR664L2Wh8vf1ebg0IbDw3D9yZQV0RdzLrFObjWFrBV Mq89Y2dIevCdnW+Zukjvx3n3eiitYDT/4bKSQB8XjAYXtOGXQPp/XQf6y/0mq/AX dR0oH8Rq21KFbobJKz0QYY2gY0SxjfDqHDjW39dg7HF+wwHW6moqL12XlvUQYMWQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvddvfedgudefiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepveehhedvveejledvvefgleevffdtjeekledvkeeg heffgfeivdejhffhledtudetnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhf ihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 68F2614200A2; Wed, 30 Dec 2020 15:22:04 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.1-61-gb52c239-fm-20201210.001-gb52c2396 Mime-Version: 1.0 Message-ID: In-Reply-To: <8aa05350-05fc-df9d-e5d6-fa0f4feb57ba@alec.pl> References: <8aa05350-05fc-df9d-e5d6-fa0f4feb57ba@alec.pl> Date: Wed, 30 Dec 2020 14:21:42 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Enumerations, Round 2 From: larry@garfieldtech.com ("Larry Garfield") On Wed, Dec 30, 2020, at 12:30 PM, Aleksander Machniak wrote: > On 28.12.2020 21:21, Larry Garfield wrote: > > https://wiki.php.net/rfc/enumerations > Why can't this be simplified to: > > enum Size { > case Small; > case Medium; > case Large; > } > > 'Small' === Size::Small->value; // true > Size::from('Small') === Size::Small; // true > > enum Suit { > case Hearts = 'H'; > case Diamonds = 'D'; > case Clubs = 'C'; > case Spades = 'S'; > } > > 'H' === Suit::Hearts->value; // true > 'Hearts' === Suit::Hearts->value; // false That's a possibility we've been kicking around. I'm considering it, Ilija doesn't care for it. :-) What's your argument in favor? Related: There is an internal "case" value that is used as well. It could be exposed as a normal read-only property, which would always be equal to the name of the case ("Hearts"), regardless of whether another "value" is defined. We're still undecided on that, too. > Also, how about using a method instead of property for ->value? We originally did. Ilija preferred moving it to a property since there will need to be one anyway to store the value. I moderately favor a method but don't greatly care either way. --Larry Garfield