Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123389 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 083A61A009C for ; Tue, 21 May 2024 22:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1716331028; bh=7YXxZf9j63TWbaUuc5fQsOOt88k4Oa2OQAwWy8OAqw0=; h=In-Reply-To:References:Date:From:To:Subject:From; b=LAzSr9InqAN5PLZFO8iv0j8aolYIJZF1lSe7V28axx4sk4MG7jmRlFlG7TrtR5IlI G40L51OgdSWFf7tQn/uLhshVikYL9SsTWMc0IgWBiA8sqve8J+/2bz2hukZWs/n6ny 6j+Sz20kO3adI/HJKUdTwrMvbThkGZYO2wSXRWthWK8nv/Pyna0YyXPkWZwE0fbijk lbMi3THkCs/TRgJT9ilWy0LfyrThvbSAty/xZfjZP3IJosKyaSFvIPO2MPa/Y6rOFF RGdTsrC02SiqTI1ViMo3fibqI+uvjWWsYR6uhrExYomNNsqStLFbFiFUyEijhBZFAb 8GrmXfeSzqG7A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9F433180004 for ; Tue, 21 May 2024 22:37:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh5-smtp.messagingengine.com (fhigh5-smtp.messagingengine.com [103.168.172.156]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 21 May 2024 22:37:04 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id AB3C61140162 for ; Tue, 21 May 2024 18:36:07 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Tue, 21 May 2024 18:36:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1716330967; x= 1716417367; bh=7VIqcyEtWWmv5S/3KQSQ3UvOXhKII5qPbWz+Z/q2SVc=; b=d /F3Jv9+pi1mKoep+jV6n76pUElN7/EpCxKsrp0slU/TTpSY05jmsO1nF0I5vUjMH Dm/sC3VpE1UVeLFxefrhZJi7PA3nK8ne0c4OhYT7+442DZBKGl/NXtIyXEJhV1jW qv68uAK5gHZtXsUvQ17wuXxkrMi0k50HcCSMeYy1m+VFJRdzxukj/tWKr9L0yOC2 xLbKna0M914EzalsKmwopT36J70Ntx2BuU+UEYRIAZN7fxy28L6vdHxsyInJ1oOX W6xv3YfPWAKbzylGte2AKouH3hw6InFo0gJDegUhedOkQwjg4msx5cFoWbvzHbvO 1c7b9YW533Wf4sVpRrYPA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1716330967; x=1716417367; bh=7VIqcyEtWWmv5S/3KQSQ3UvOXhKI I5qPbWz+Z/q2SVc=; b=KRDpMrqZUnIw59jOiMUmk+CJnHbCWsbkWHm4OXcBWXPc P7l9bVgw+SSoQF3GR/L/Spov6zxnW6eU9HCWQOtQO2Kxe/byxbu+4qlpBK7FfjFr DkdsNgy0+Ab+4Adddy40haSYgQLKCvO0NVGjmZR9WDD8bG5RZQFxOdbvaBu4O+/L GcDKDH/H9r69OkbIp2zUb3K1HRHeuXIhnhLmUT1AoZo9Yke4yyQZs7JtNKw01Mq+ qjklaLPyqFLloTSoWixwNfxHR764ZcpCx3MU4q2NB4LloarmeGaurlsM7ERw5Fq3 cIGWQCIRol8g/5px0Gl6iT9YnCMDPfYI2mz4mGbQVQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeifedgudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeejleduueffveevvefgffekjeetvdetfeetjeefvedv udfgiedtuddvgeevveejhfenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhpvggrkh gurdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 571561700093; Tue, 21 May 2024 18:36:07 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-480-g515a2f54a-fm-20240515.001-g515a2f54 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: References: Date: Tue, 21 May 2024 17:35:47 -0500 To: "php internals" Subject: Re: [PHP-DEV] [Discussion] Content-Type: text/plain From: larry@garfieldtech.com ("Larry Garfield") On Tue, May 21, 2024, at 5:30 PM, Bilge wrote: > Hi Internals, > > I struggle to understand the benefit of "basic" enumerations and their > diminished API. In particular, I often find myself wanting to use > `from()/``tryFrom()` to convert a string to an enumeration. To do this, > I must convert it to a "backed" enum and copy & paste each name to its > value. In all other regards, I still want it to behave like a "basic" > enumeration, so I won't abuse the value of the names to act like a > mapping; the values will always mirror the names, and if I need to do > any mappings, I'll add match() functions. > > My question, then, is why can't basic enumerations have these semantics > by default? Or, to state it more concretely, what would be the downside > to having all "basic" enumerations actually being "backed" enumerations > whose values implicitly mirror their names for the purposes of > converting to/from strings? Would this not make basic enumeration more > useful without any particular downsides? > > Kind regards, > Bilge Making enums not be "fancy strings" was a very deliberate decision. The RFC covers that some. There's more information in our comparison research here: https://github.com/Crell/enum-comparison And I wrote an article about enum usage a while back here: https://peakd.com/hive-168588/@crell/on-the-use-of-enums --Larry Garfield