Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115380 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 78087 invoked from network); 9 Jul 2021 10:45:15 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Jul 2021 10:45:15 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 93D53180502 for ; Fri, 9 Jul 2021 04:07:44 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 04:07:44 -0700 (PDT) Received: by mail-ot1-f41.google.com with SMTP id z18-20020a9d7a520000b02904b28bda1885so7578971otm.7 for ; Fri, 09 Jul 2021 04:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=dmmFlJpiXTy555qK4HA1L0i2AaesqXZWGbZAjWeyqSE=; b=UcflrHctwYDB6z2Ut+V3U8qTsFlgsELVh2Bl7dpvGR8KeKERJwikL/Uj+2yK9hCw4N M5X8IMCzS5JULYRIFwRW2oqVFCeH6e6wXSJA9rVxTy2I/vngjvqoBBqRb204Fbq2vUhp MtLCkoSLGYczC2gk+bPeOYeQiFiARkih7TMpPn5ceqBUvoZgHjE2ZDeut0N8xdORBpjQ CEepiNBoN2EKiZJpPejV9poy/QO5Ad9O4Am/G+LriIFVpOJyOTC0WyeWeDy+bkIbTWzo FjbracbUDB798R9EKxxJQ6+N2T8ZHlPoARdMDp9NkYpvt9HP2FAlrc3XjSP57V0AYdnG 0I2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=dmmFlJpiXTy555qK4HA1L0i2AaesqXZWGbZAjWeyqSE=; b=ZtdrR99WTyUVgG9tIllOtACs7h5xNwhKxLai40oAspipCaBMWIaaH01I7hUSOpxLqL VS8lHWU4sJXr/8Zja9rPQKp+SfMaUTEHrcaUcIpzqrSEp7YacnaLCnMAuM0iCi7QyKcO 30gruARULvlXP48yj/iQ/jAivYgdtAD90+VlL70vyQ0Z6J+TxIdYazGQQ1iTKrfAaYGd Bu4bPuPIoedYLFkCxSlzLKSzvK7qd+sJQBLH20EeHyD9N9sqs8bGEEjV+ilob6xDnumr +TZ+ia9zlVi+2mAmf+px2QfLkDSIZ2aB5fsRSG8naB0XzsECBjUX4CzAVsphUr+nk0vL Ah8w== X-Gm-Message-State: AOAM5338aURrXOGItLKfl6FX0bWWkEmv4xL07+Vch4VweAQnA/h3VGT1 LB+nE9jteQkaFsoaT5lCOGNnoRQJUfalpibXkhMdHkqyIV8= X-Google-Smtp-Source: ABdhPJxYpxP6N/ktXp6lP5kj8MtitpETmViOf05myq/v0WIHpSp7J+rHWHgxSM0J5OrKzYTV2JnR1OgpIX68b4k1f6o= X-Received: by 2002:a9d:a83:: with SMTP id 3mr7666534otq.278.1625828863028; Fri, 09 Jul 2021 04:07:43 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6839:1c9:0:0:0:0 with HTTP; Fri, 9 Jul 2021 04:07:42 -0700 (PDT) In-Reply-To: References: Date: Fri, 9 Jul 2021 13:07:42 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000d8af6d05c6aec710" Subject: Re: Fake Closure Comparison From: krakjoe@gmail.com (Joe Watkins) --000000000000d8af6d05c6aec710 Content-Type: text/plain; charset="UTF-8" The test included is quite comprehensive. Cheers Joe On Friday, 9 July 2021, Larry Garfield wrote: > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --000000000000d8af6d05c6aec710--