Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112435 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 32182 invoked from network); 5 Dec 2020 21:00:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Dec 2020 21:00:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D44A21804C3 for ; Sat, 5 Dec 2020 12:28:58 -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 ; Sat, 5 Dec 2020 12:28:58 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 9A514466 for ; Sat, 5 Dec 2020 15:28:57 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute4.internal (MEProxy); Sat, 05 Dec 2020 15:28:57 -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=Va3TX3 pURonCV085RR/VUzA8XWTxxK4RBJ7+OG5UnZc=; b=RJWmHxEMDfv4Z+9L0KFcC0 I/KlMC5AM4rOI4hEjgfzSGNvkN6qJoE1VfkS5C40w9y+0xlGwLNi9nONE48WlkuS CeZkWbY17xcA6ubCNfzoaB/K8hRH/4o890j5cBHtRX4lAXKAA76s1VLVDa5L3/Wd lnaKSAuuRfIiyOPH6+8jrL1D5Q5HXLASe3TaXi+pW7+SPXzWsxNmUTQN0xjJhxAT CuEDgRUzdJoArzwwNKhJUFJvYzuQpibNmwOLynwlF06e9ExukX5JS688PSzBfLoj RPJBpnDe2B7HLJlSSyG7a1Gn/+zf7FlLbhFBAsE7tivAbywJ8b9QQD3dxHNM0D9w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudejtddgudegudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepveehhedvveejledvvefgleevffdtjeekledvkeeg heffgfeivdejhffhledtudetnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhf ihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id E99E414200A2; Sat, 5 Dec 2020 15:28:56 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-622-g4a97c0b-fm-20201115.001-g4a97c0b3 Mime-Version: 1.0 Message-ID: <79044037-4cd4-4065-a3c1-39a4deea3e09@www.fastmail.com> In-Reply-To: References: Date: Sat, 05 Dec 2020 14:26:43 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Enumerations From: larry@garfieldtech.com ("Larry Garfield") On Fri, Dec 4, 2020, at 5:24 PM, Larry Garfield wrote: > Greetings, denizens of Internals! > > Ilija Tovilo and I have been working for the last few months on adding > support for enumerations and algebraic data types to PHP. This is a > not-small task, so we've broken it up into several stages. The first > stage, unit enumerations, are just about ready for public review and > discussion. > > The overarching plan (for context, NOT the thing to comment on right > now) is here: https://wiki.php.net/rfc/adts > > The first step, for unit enumerations, is here: > > https://wiki.php.net/rfc/enumerations > > There's still a few bits we're sorting out and the implementation is > mostly done, but not 100% complete. Still, it's far enough along to > start a discussion on and get broader feedback on the outstanding nits. > > I should note that while the design has been collaborative, credit for > the implementation goes entirely to Ilija. Blame for any typos in the > RFC itself go entirely to me. > > *dons flame-retardant suit* > > -- > Larry Garfield > larry@garfieldtech.com Thank you everyone for the feedback so far! I've updated the RFC with a few changes, based on discussion here and elsewhere: * Clarified that "enums behave like objects unless otherwise specified." That should clarify a lot of edge case questions. (Which is specifically one of the reasons to build off of objects. We can inherit answers to most edge cases.) * Primitive-backed Cases have been renamed to Scalar Enums, because "Primitive-backed" is just too clumsy to say or write all the time. * There's now formal internal interfaces defined for Enum, UnitEnum, and ScalarEnum to define the methods mentioned. These serve as both documentation and to allow user-space code to tell when a value it's dealing with is an enum, and a particular type of enum. (And therefore what enum methods are available.) * Added a value() method to ScalarEnum, to make it easier to get at the scalar equivalent arbitrarily. * Fixed a bunch of typos. * Updated the reflection section to have getType() return a ReflectionType rather than a bare string. (The patch will be updated for the above shortly as Ilija's time allows.) --Larry Garfield