Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125004 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 4A4381A00BD for ; Fri, 16 Aug 2024 22:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1723848442; bh=UO8i/3Z0y78tMuscGQYuwikdl0zvcCweFB1Po++WcE8=; h=Date:From:To:In-Reply-To:References:Subject:From; b=BjJODcE52okm6eCivs2YJcQHD6+s7x0wEERh6Y6u3RPCPbsgsRg36dhbzDnXY4t6X aZw9rpWEb/+wuy1rwBxWvqdxuA77nkACtnVXVagg1nUZ64JknsMyNU7Ib3Conq22EU h/I4WwL3mhRkIYB63dOvOjHj49tnSuXXd89kElDQAjtub4Cxd0Nh406IBnDZa3ZxZ6 AtkXCiDu1RburU+Zb30PXUgUaWOy/2tT59ajhGuYgHJ0Qdtk7qGxjcvqi/kwZSJin/ 0NYdj6uigYpEWxOFuXuMrSHrIhF9ty2BlNE3f0zmfQZh0nNozAqatl3YmgFwBO4rF7 NPgF91dM9HZ0g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6D2C1180389 for ; Fri, 16 Aug 2024 22:47:20 +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, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout7-smtp.messagingengine.com (fout7-smtp.messagingengine.com [103.168.172.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 16 Aug 2024 22:47:18 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id CA453138FC62 for ; Fri, 16 Aug 2024 18:45:30 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-03.internal (MEProxy); Fri, 16 Aug 2024 18:45:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=fm3; t=1723848330; x=1723934730; bh=G7XCM+1ErHulM32Ri8nvZ /pnFj6BReZ9BUbChWZ8egk=; b=JqC+m90PfemLwgMyPeKVj2cpEHO6SzOLCKqdf Q6UoFZCZG/peJmGgsVusuQoSLJ04Z3baEoXAat22CN8nRjhl6pq3gp25DXw0WWS/ sVlH87woQtGKBrYl6m1dYrV38XUGyfm8gI8C9r+mp95v2prIpYFiIHK+2D843Vca jVPJ/1LJJ9/cAqYVJkIRUn/BLF2QLgSf3XDv0N9CJ0C4oF+CoSQgryKjZ5GbYhP0 2Seem65E3fIDesTPR0Kq28Q7h6muWLuA9lWH6TxmqC2+YAuGwzoHdHsLdsFysLZe Z1juJcQAqlPUjnZaiMiVwzKtOnyC2CHpXqbh5Wtr8sNEABzEQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=fm3; t=1723848330; x= 1723934730; bh=G7XCM+1ErHulM32Ri8nvZ/pnFj6BReZ9BUbChWZ8egk=; b=q w3aG6Uj6/BbmLzgfj3vAkN3+VQVBXRlr6rriB3DRkLKgQpVIh+5rpxtWXpvepmKj +ThYItSgDsYfykRhn5aaruOYKW7pkFRJWrtUXXRtrWcFlusP7DnGZ9hWy7GTY8eB 0UGAbFeZFz4Agw5/xOz133Ea+Z49eE9TuPAz1mUYmloT3BqH/iGOOqWfK0hqWqsV 345LxYkubGlN2mfQq6vPeKnLSqnFqQstktPsrgA3b46QrJyEZbGuxvJ6DWBWo1W2 88/7s1hZaZtbr5pxuo7zVThWBRNPFXHxquSIap+/jvD6lnSt+BZwBTBYy3YJOUnj o4ighVnev78z47TuTFEQA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddtledgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthejredtredttden ucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfih gvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpedugedvlefgueegheefjeet ffduveeltefhfeegjeffffelgedttdevkeegkedugfenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggt hhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpth htohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 96B11940067; Fri, 16 Aug 2024 18:45:30 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 16 Aug 2024 17:45:10 -0500 To: "php internals" Message-ID: In-Reply-To: References: <501db7d2-55e1-4b20-bb6e-1e079aa4939b@scriptfusion.com> <59BED9FD-EB77-4B44-9F93-7FC573EC7F14@getmailspring.com> Subject: Re: [PHP-DEV] String enums & __toString() Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Fri, Aug 16, 2024, at 5:01 PM, Bilge wrote: > On 16/08/2024 22:51, Gina P. Banyard wrote: >> On Friday, 16 August 2024 at 22:01, Bilge wrote: >>> >>> >>> On Fri, 16 Aug 2024, 20:57 John Coggeshall, wrote: >>>> >>>> I'm not seeing an obvious upside to forbidding straight out `__toString()` >>> >>> I tend to agree, but Crell will drive by in a minute to drop some philosophical nonsense about why we're all wrong :^) >> >> If you could avoid disrespecting a contributor to the project, this would be appreciated. > To be clear, I have nothing but love and respect for Larry. > > Cheers, > Bilge I appreciate that. :-) To the original question, there's two reasons that __toString() was deliberately omitted from enums: 1. To discourage their use as "fancy strings". Enums are their own type, independent of any other. Making them usable as 95% strings partially defeats their purpose. 2. We still intend to add associated values to enums at some point (aka ADTs, aka tagged unions), and... we're not really sure yet if that will impact __toString() at all. It may, it may not, we don't know. So for now we're keeping our options open by disallowing __toString(), in case it ends up being needed for some ADT-related behavior in the future. Point 2 will, hopefully, resolve itself in time once we can get ADT support in. Point 1 will remain, however. --Larry Garfield