Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120165 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 96521 invoked from network); 30 Apr 2023 15:59:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Apr 2023 15:59:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D53BF180503 for ; Sun, 30 Apr 2023 08:59:27 -0700 (PDT) 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29838 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 30 Apr 2023 08:59:27 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 29842320091E for ; Sun, 30 Apr 2023 11:59:25 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Sun, 30 Apr 2023 11:59:25 -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:sender:subject:subject:to:to; s=fm3; t=1682870364; x= 1682956764; bh=C4LzRLS97Lo7dWduuHvuSKu408H1Z0dESOUQ5EdssMk=; b=p AWnYUBBagAgpFaS0bAOAeHb/DHtrQExHR/6XLgfk0Tx1G/0KFDPBTsdWWEuApzyo UeSTwIXFRCEHezWk531mZ/COpmVvgg4h3ZdfapHyDoox9P/jw/GM939CESMNO7a1 ahmBYy6Lo+9/QPbN3ZHbiJvauy9mV2JutfqG6FdB70P2uMtFeXY/KdWIZxr7iKRZ oZ5T2THJgcuWOus9juLT5lsao9t+0xYBYkcum1TGLxy68cNSEK9vyUTHI1/FzrdM B7akul9NGWKl/TLUa2ezSS/QEp+1mJI+CkuIa11fGw3ATR11DX/IsHQ9A4WHy68O G9Gjet684DXytWrM9TKow== 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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1682870364; x=1682956764; bh=C4LzRLS97Lo7d WduuHvuSKu408H1Z0dESOUQ5EdssMk=; b=Du9f5DALdOT+oGo7dstEzetZjDiFn 5Lq9RukLHlhGfE99K4Oplp0lPXY1r+FOhXBx5SgKU7RLfXt9bEuIu3UIDCEIOPLw yONFhZ7ccHoGX1CW7WB2Bdw8zYQS0zU1m71tfg1CqXfLJ55Pcw4FqUjft7Xv7i1a Sbjk16AhNZ+0N5pLuEu0EMC0FXQe67kjvWWZbdFkmEqyqpxDm8ADPgeqDOXJvIh9 /lAvdX4jD7lvY1NkAxRXGamaE6McA6/rrSoecpshs84P+Y4SVUkVQlh4NFY/9gEo JWc6CmU23qZMZfoqnY+hPBdjjuC1acfc1XyOZXdd0+5FCU2n0Cth/+DSQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedvvddgleejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeevheehvdevjeelvdevgfelvefftdejkeelvdekgeeh fffgiedvjefhhfeltdduteenucffohhmrghinhepphhhphdrnhgvthenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhi vghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 690FA1700089; Sun, 30 Apr 2023 11:59:24 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-374-g72c94f7a42-fm-20230417.001-g72c94f7a Mime-Version: 1.0 Message-ID: <317fcbc7-120e-4d1f-b7d6-14bbeef9a18e@app.fastmail.com> In-Reply-To: References: Date: Sun, 30 Apr 2023 10:59:04 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Request for RFC Karma - Enum value semantics proposal From: larry@garfieldtech.com ("Larry Garfield") On Fri, Apr 28, 2023, at 4:47 PM, Garet Claborn wrote: > You are correct, thank you. > > The RFC draft has been posted to > https://wiki.php.net/rfc/treat_enum_instances_as_values > > -Garet I have already explained at length on the PR thread why this is a fundamentally wrong way to approach Enums. We absolutely should work to improve the Enum collection story in PHP, but silently casting Enums to scalars is the wrong way to do it. As noted in the original Enum RFC: > As objects, Enum cases cannot be used as keys in an array. However, they can be used as keys in a SplObjectStorage or WeakMap. Because they are singletons they never get garbage collected, and thus will never be removed from a WeakMap, making these two storage mechanisms effectively equivalent. WeakMap may not be not ideal, but it is more ideal and effective than introducing silent Enum->primitive casting, which we have explicitly and deliberately avoided until now. It can still be used in mostly the same way as arrays are today; the only caveat would be if you're expecting to use a mix of different types as keys, in which case the answer is to fix the code instead because that's already a broken approach. --Larry Garfield