Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120027 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 4154 invoked from network); 13 Apr 2023 13:47:42 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Apr 2023 13:47:42 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 49CED180506 for ; Thu, 13 Apr 2023 06:47:41 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 ; Thu, 13 Apr 2023 06:47:40 -0700 (PDT) Received: by mail-ej1-f54.google.com with SMTP id ud9so37380120ejc.7 for ; Thu, 13 Apr 2023 06:47:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20221208.gappssmtp.com; s=20221208; t=1681393659; x=1683985659; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iyZidsZ8EkaVsNXgZ+nu6B5TbZ4Z8CFFE8njr5nLZCw=; b=csH6Sclx37qCOdfxBEYdSi1Fcefx+o9HHDv9aXmqqFCDRQkC83x8njjtx4vDiskDt1 tygEH3CpnnUXqetWoFrePGewWhNfatgO1CnI/BH8NJHjXkrd4nrtkRhcUaKyNnLhTeCf 2f0Q42S90tB8tonoSdB6qdBPzTruenqPJWDdqJVmlJrSZ/PZeecfnIINfX9IlgBe7Xk0 sywRgV9CmQZxH9XaOupH/oFz+OhmNo6+nZSvQeo9uVnoclBKo93aKOWcOFF2S7R/i9eq bsJXy7YYnZ2gNFfvIniX5hElZ30V1s2NoeBU0wllGpfPzQ6NV6M2DAyoix1N+1SZ8dX+ 3hcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681393659; x=1683985659; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iyZidsZ8EkaVsNXgZ+nu6B5TbZ4Z8CFFE8njr5nLZCw=; b=OEWHdvC8f15dJUhKEl9S4/MC6paRDRCUUlcg7B4U+swF4b7I1kFzwlKJtpxVGuJUlK J37yJhmYWE+7/TiPyGYB9OwEoiTBMbEQgNJFhDzotPyTaHMhuH6RTSoEUYo/gDjVzJjV 1SY3PFFVQct8+XsBATUCd4qKVwB3pIWs4PTtaiI6H0CcURDU8AQE8PDy6irmZ3sB3cRA ymdscVsb130ip5RO5WFPazeij11ABfgddIyc25Bwi+2s1xV6ZnwHkvUwDIbJRNd2NXng 38cLjL1OCu7BcknT1GOaNjfAodAd9tbfIxbf5s/ImksSFeP7rVq1B1Xdzqb/9sQZND7H 7D5g== X-Gm-Message-State: AAQBX9d0de9+52GADwZTggFwBAMXAU1CIGzZFbs+mwSLX/CAnAFr+dDJ LA1WseW6SPXp/Wktpy81ZoIF0SGf1jSOKLAhQ6UY3Q== X-Google-Smtp-Source: AKy350Yspg8oihRzAdLnt8ysh7poXdxYG0SiNjjpin9S+pq1CVw4Yo1YaCXhtKdKXvGQrTo9T9gUaDlJlyoCe4+hR1Q= X-Received: by 2002:a17:907:5ca:b0:94a:6df6:20aa with SMTP id wg10-20020a17090705ca00b0094a6df620aamr1423313ejb.8.1681393659452; Thu, 13 Apr 2023 06:47:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 13 Apr 2023 14:47:28 +0100 Message-ID: To: Robert Landers Cc: Eugene Sidelnyk , PHP Internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] First class callable syntax for instance methods From: Danack@basereality.com (Dan Ackroyd) On Thu, 13 Apr 2023 at 07:30, Robert Landers wrote: > > This has been brought up a couple of times, but I can't seem to find > it. https://externals.io/message/119392 https://externals.io/message/120011 > I don't think something like this is possible with the current > implementation of first-class-callables (it would need a major > refactor). It's not currently possible, but it wouldn't need a huge refactor...we could just do what Java does: https://www.baeldung.com/java-method-references https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html // If we copied the Java way of doing it, this: // $fn = Verification::getId(...); // $fn would be equivalent to: $fn = fn (Verification $v) => $v->getId(); And if the method of the class has parameters, those would be after the first instance parameter: class Foo { function bar(int $x) {} } $fn = Foo::bar(...); // Would be equivalent to: $fn = fn (Foo $f, int $x) => $f->bar($x); I can't see a technical reason not to do it like this, but some people seem to be having negative gut reactions to it, and it's hard to persuade someone about aesthetics. Notes here: https://phpopendocs.com/rfc_codex/class_method_callable cheers Dan Ack