Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112204 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13983 invoked from network); 8 Nov 2020 09:16:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Nov 2020 09:16:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DFDE71804B5 for ; Sun, 8 Nov 2020 00:38:20 -0800 (PST) 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,HTML_MESSAGE, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-mahalux.mvorisek.com (mail-mahalux.mvorisek.com [77.93.195.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 8 Nov 2020 00:38:19 -0800 (PST) Received: from 8e589eb6c68b (10.228.0.142) by mail-mahalux.mvorisek.com (10.228.0.4) with Microsoft SMTP Server (TLS); Sun, 8 Nov 2020 09:38:16 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_023db9b7d065eaddb4c5016f4e19b216" Date: Sun, 08 Nov 2020 09:38:15 +0100 To: php internals In-Reply-To: References: Message-ID: <35412c9dc3484c321e813a1b462417fe41707a948ec5e53069c79d3ac7615d57@mahalux.com> X-Mailer: SAP NetWeaver 7.03 Subject: Re: [PHP-DEV] [RFC] Support for ::function syntax From: vorismi3@fel.cvut.cz (=?UTF-8?Q?Michael_Vo=C5=99=C3=AD=C5=A1ek_-_=C4=8CVUT_FEL?=) --=_023db9b7d065eaddb4c5016f4e19b216 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8; format=flowed Hi, what about resolving directly to Closure? strtoupper::function === \Closure::fromCallable('strtoupper'). $this->method::function === \Closure::fromCallable([$this, 'method']). With kind regards / Mit freundlichen Grüßen / S přátelským pozdravem, Michael Voříšek On 8 Nov 2020 00:41, as@php.net wrote: > Hello internals, > > Looking for feedback on the idea of supporting `::function` syntax (or > `::fn`) for consistency with existing `::class` syntax: > > $arr = ['apple']; > print_r(array_map(strtoupper::function, $arr)); > > (Apologies if this has already been discussed. Hard to search for > colon-colon-function.) > > Benefits in my view are readability and potential use in static analysis. > Downsides (as implemented in proof-of-concept) are that it can be > needlessly littered in a lot of places, and that it breaks class consts > named `function`. I'd vote against it in its current state, but if people > like the general idea maybe the drawbacks can be addressed with a better > implementation. > > Examples: > https://gist.github.com/adsr/2c0b9243986418af3cecf8046657304b > > Proof-of-concept: > https://github.com/adsr/php-src/commit/07bb24243022ccef5823f6977d231f3535a48a07.patch > > Adam --=_023db9b7d065eaddb4c5016f4e19b216--