Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112681 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 97456 invoked from network); 30 Dec 2020 20:13:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Dec 2020 20:13:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 870E3180384 for ; Wed, 30 Dec 2020 11:48:37 -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 11:48:37 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 7DAE7A8B for ; Wed, 30 Dec 2020 14:48:36 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute4.internal (MEProxy); Wed, 30 Dec 2020 14:48:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding: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=APBx2vN7SbLLQQgsfvN6t7OOp73r1TwrO8QJ9lrQh Ag=; b=Moxj/ZJJjFZw4+ZX46VfAOt1V1EbSir7S+qm1nqaf6fmEhL1tKNeFjY9Q 1QMtIZZ5l7S4M2uhDse88FVLkxjexR5AtQIKUoQLYyh4dqVdAnLwtaJ5uVDMrrSB reTBpLP3IwAhPxBQpxxZTAYGjBF3JkJut820Bj/A0Mkh0qdyo4lFOFJYHMB8wqgn ITpTKGVO/jsdqEIUiQ360ng1T1H5iuJwSnWUR0l1etlOO/Wgmd3+Lp412rlcWQrC qFeSkge735muTqEHDzmV62a/qELOqa9odPMfVSvxKNykv7ObbyBKrYr6DqtXNXcs 66P4FTORNCds3ImH9A6+05vyJZMcw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvddvfedguddvlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdfn rghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrd gtohhmqeenucggtffrrghtthgvrhhnpeffffffjeffudfggeevvdeitdetvdfgjefffeff jeelfeejteevheeghffhvdfgleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id D12AB14200A2; Wed, 30 Dec 2020 14:48:35 -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: <012f426d-ff07-fce7-d642-c64bafa5aaf5@gmail.com> References: <012f426d-ff07-fce7-d642-c64bafa5aaf5@gmail.com> Date: Wed, 30 Dec 2020 13:47:58 -0600 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Enumerations, Round 2 From: larry@garfieldtech.com ("Larry Garfield") On Wed, Dec 30, 2020, at 6:27 AM, Rowan Tommins wrote: > On 28/12/2020 20:21, Larry Garfield wrote: > > After considerable discussion and effort, Ilija and I are ready to o= ffer you round 2 on enumerations. >=20 >=20 > Thank you both, again, for all your efforts. I'm pleased to say that I= =20 > like this draft even more than the last one. :) >=20 > A couple of points that occurred to me reading through: >=20 > - The magic methods section lists __call as allowed, but not=20 > __callStatic; was this deliberate, or just an oversight? More oversight; the reasons for not including it initially aren't really= good reasons, so we'll unblock that. > - Under Future Scope, the "Grouped Syntax" sub-section says "That woul= d=20 > only work on the simple, non-primitive-backed case with no methods=20 > defined [...] it is unclear how common that will be in practice" This=20= > caveat doesn't apply to the current proposed syntax, and should perhap= s=20 > be re-visited. >=20 > Given that this is currently a legal declaration: >=20 > class Suit { > =C2=A0 const Hearts =3D 'H', Diamonds =3D 'D', Clubs =3D 'C', Spades = =3D 'S'; > } >=20 > It seems fairly reasonable for the enum version to allow the same synt= ax: >=20 > enum Suit: string { > =C2=A0 case Hearts =3D 'H', Diamonds =3D 'D', Clubs =3D 'C', Spades =3D= 'S'; > } >=20 > Or, for a non-scalar enum: >=20 > enum Suit { > =C2=A0 case Hearts, Diamonds, Clubs, Spades; > } That's partially left over from when we had per-case methods, where grou= ping would be highly fugly. However, I'm still advocating for tagged un= ions (in a future step) having per-case methods, and that would make the= grouping syntax fugly again. It's trivial to add later, so for now I t= hink it's best to skip. If we find later on it doesn't get in the way o= f anything it's an easy addition. --Larry Garfield