Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115379 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 76288 invoked from network); 9 Jul 2021 10:36:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Jul 2021 10:36:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 155A61804B0 for ; Fri, 9 Jul 2021 03:59:25 -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.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 out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 9 Jul 2021 03:59:24 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 519FC5C00E7 for ; Fri, 9 Jul 2021 06:59:22 -0400 (EDT) Received: from imap43 ([10.202.2.93]) by compute1.internal (MEProxy); Fri, 09 Jul 2021 06:59:22 -0400 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=fm3; bh=VCPCQT NrGgMueDh5m136eEo6FvRFPTuVyXx6d3Z7UL4=; b=IQh6mVsf9B4Hv8Isq0/MrP 2Kol09waeDh5K3Z+1wtQCMwPcHv7ZIlr7bao9oe2DTybzypJQfklqY5Q0tHISAUc P/5FkGPZ3jWlamMVM4I7ANmF4VYFnLa+o+n++X2qHKsxohPOSOiieoG+MI/98O2t sIUZs4mx0JkX+jsTYlDBh5oA8JClnV3QNrRCqLdiOwodZ1MMeLju16dFyaESi4eH PlxyonvuQ1+xO+ss3oewXTjHZvjlU7xE2Cy8PZlWX+AuQSxjDpZvHnmXAhU1Vc98 A2HOGqrVJWE8oaKoyA5G9q2y6YYGHIkB9G0HuzlnDFiA7pcDqrY8eQmnRobJdb9g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrtdeigdefudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnhepkeetleehffegfedvudefueejkefhvddtueeuvdevteei veehledugeejudfhhfetnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghr fhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id E2575AC0088; Fri, 9 Jul 2021 06:59:21 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-531-g1160beca77-fm-20210705.001-g1160beca Mime-Version: 1.0 Message-ID: In-Reply-To: References: Date: Fri, 09 Jul 2021 05:59:01 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Fake Closure Comparison From: larry@garfieldtech.com ("Larry Garfield") On Fri, Jul 9, 2021, at 4:51 AM, Nikita Popov wrote: > On Fri, Jul 9, 2021 at 10:45 AM Joe Watkins wrote: > > > Morning internals, > > > > While discussing some of the details of the first class callable RFC, it > > became apparent that fake closures (created by Closure::fromCallable) are > > not currently comparable in a useful way. > > > > Although this is not directly related to the first class callable feature, > > it's likely that the proliferation of this kind of code will follow, so now > > seems like a good time to fix the problem. > > > > https://github.com/php/php-src/pull/7223 > > > > Any objections to merging that in master ? > > > > To clarify: What this implements is that > > $strlen1 = Closure::fromCallable('strlen'); > $strlen2 = Closure::fromCallable('strlen'); > var_dump($strlen1 == $strlen2); > // bool(true) with this patch, previously bool(false) > > The same would also apply to the first-class callable syntax, i.e. after > this patch strlen(...) == strlen(...) would return true. > > Regards, > Nikita Seems reasonable on the surface. My main question is how far that extends. Does it work *only* for Closure::fromCallable()/FCC syntax? What if the argument is not a string? How deep does the comparison go for, say, objects and methods? class C { public function beep(string $a): string { return $a . 'beep'; } } $c1 = new C(); $c2 = new C(); $strlen1 = Closure::fromCallable([$c1, 'beep']); $strlen1b = Closure::fromCallable([$c1, 'beep']); $strlen2 = Closure::fromCallable([$c2, 'beep']); // What do these do? var_dump($strlen1 == $strlen1b); var_dump($strlen1 == $strlen2); --Larry Garfield