Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94933 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86230 invoked from network); 8 Aug 2016 15:16:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Aug 2016 15:16:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain brzuchalski.com designates 188.165.245.118 as permitted sender) X-PHP-List-Original-Sender: michal@brzuchalski.com X-Host-Fingerprint: 188.165.245.118 ns220893.ip-188-165-245.eu Received: from [188.165.245.118] ([188.165.245.118:34679] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6B/C1-33134-132A8A75 for ; Mon, 08 Aug 2016 11:16:02 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id CC36F298423C for ; Mon, 8 Aug 2016 17:15:58 +0200 (CEST) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4tqYd0nF9jKP for ; Mon, 8 Aug 2016 17:15:54 +0200 (CEST) Received: from mail-qk0-f171.google.com (unknown [209.85.220.171]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id F17DB298423B for ; Mon, 8 Aug 2016 17:15:53 +0200 (CEST) Received: by mail-qk0-f171.google.com with SMTP id p186so199212698qkd.1 for ; Mon, 08 Aug 2016 08:15:53 -0700 (PDT) X-Gm-Message-State: AEkoouswXB2n1tRZhAAhl5Jj4oQ7U+Ibr3IPFMJbNd23FkTNYGDrv2SXJ3mzFnQNaBhxxVEaR5LjlTbTGWYttg== X-Received: by 10.55.123.5 with SMTP id w5mr29535045qkc.172.1470669352329; Mon, 08 Aug 2016 08:15:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.53.155 with HTTP; Mon, 8 Aug 2016 08:15:51 -0700 (PDT) In-Reply-To: References: Date: Mon, 8 Aug 2016 17:15:51 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Rowan Collins Cc: PHP Internals List Content-Type: multipart/alternative; boundary=94eb2c065db4540366053990e4ae Subject: Re: [PHP-DEV] Function auto-loading From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --94eb2c065db4540366053990e4ae Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable IMHO if there were possibility to provide scalar objects like in Nikic extension https://nikic.github.io/2014/03/14/Methods-on-primitive-types-in-PHP.html most of str* and many other functions could be called wythout FQN simply from variable. Most of global scope functions interacting with scalars could be called throught object handlers. In many legacy applications there still could be possibility to call global functions. Most of legacy applications have no namespace (Wordpress) so there is even no need for FQN for function calls. 2016-08-08 16:56 GMT+02:00 Rowan Collins : > On 08/08/2016 15:36, Levi Morrison wrote: > >> I feel like the problem here did not get across properly. Calling the >>> autoloader if a global function with the name exists will totally kill >>> performance. This means that every call to strpos() or any of the other >>> functions in the PHP standard library will have to go through the >>> autoloader first, unless people use fully qualified names (which, >>> currently, they don't). This is completely out of the question. >>> >>> >> Interesting. I come to a different conclusion: this a great opportunity = to >> get developers to use the fully qualified names. Performance is an >> incredibly motivating force even in many situations when it shouldn't be= . >> > > An example just to focus the mind: > > namespace Lovely\New\Code; > > class Blah { > function __construct(array $foo) { > foreach ( $foo as $item ) { > if ( strpos('blah', $item) !=3D=3D 0 ) { > // ... > } > } > } > } > > > This will *repeatedly* call the function autoloader for > "Lovely\New\Code\strpos". The fully qualified name in this case is > "\strpos". > > I think saying "add a backslash in front of your function names to avoid > them being slow" will just lead to lots of "lol wtf php sux". > > If we wanted to make the \ mandatory, then the name resolution for > functions could have had no fallback, just like class names. The reasons > for having that fallback presumably still apply, so it doesn't make sense > to now declare it "broken by design, please avoid". > > On the other hand, saying "you can autoload functions from another > namespace using qualified names or 'use function'" sidesteps the fallback > issue, and sounds like a reasonable, non-BC-breaking, feature. > > > Regards, > -- > Rowan Collins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 pozdrawiam -- Micha=C5=82 Brzuchalski --94eb2c065db4540366053990e4ae--