Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94931 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81821 invoked from network); 8 Aug 2016 14:58:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Aug 2016 14:58:28 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wm0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:36589] helo=mail-wm0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/E0-33134-41E98A75 for ; Mon, 08 Aug 2016 10:58:28 -0400 Received: by mail-wm0-f49.google.com with SMTP id q128so124431836wma.1 for ; Mon, 08 Aug 2016 07:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=fEm9IQYBC/mn2Z2Gm+QNwEM6OtbHZU29kv59K/StA2w=; b=vCXqsgqVIRDKfYIJhucrQs0O69vxixXRsh73RH192W8PJju2xIlCId32OieeVosObt yHzlyIU+xE25yeMOGqm5npCMHI8NmicHqZJQ+Yr+FZE2c58ZgffPFNKqJ0WhM7d7h88i vzkqMVqXPZi1xNsa47FGTObZJC1+BBofE5EFIhLJhowbCLJIc5JAq+PKmdI/35SCF4oZ 9MKydxtIObYP8Y14VdUkEYme1p0WuEtcIdtyPL6QaMRpqJL6KMzbCZ2UB6ud5RY6UV9o CeWxIUWmlM1qaoqBwjO1rxOyI/IeEQvWr+NoUOIi4iOF6qzXMKJMjujtKDZdLq4FcadH f7hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=fEm9IQYBC/mn2Z2Gm+QNwEM6OtbHZU29kv59K/StA2w=; b=M+1+UBwCVDpd8+57WR9VfbGjgI2g16K9Mqkk8sLMMU3B4D7YvGhbJFgomhPVhRbXP4 toDmXArutYKpKnp0zkSZ82k2lqpYVi/tzsCI2j5hzlUzwVsLswGZM4VgP/VgCZS8Lpkw bUOJ88wG5j6uSKZQ3XBUgtCK9etxV5d+VnsqFtArig8+KVFfK9hHH4wYe5eXTJ4fd38U IxDG+6WzGbIRLxvwMtE1l8r6uVjvCs3nKREFdAvrP9cobrqscHp0ye5VNQL53GzNkGr0 IplkLtTpavgW2xuHYnoecDZxOR9sO2DyeRcX8XyCfpRJp6PbXBiXkUPkFtXzRAaEo2Le P61w== X-Gm-Message-State: AEkoous5ErYXqBLjytihbeskoLd7IV3iq6UjVemjE0Lh7BJZS8DJaa9EEdp38WSXSpXWSA== X-Received: by 10.28.32.77 with SMTP id g74mr15617638wmg.45.1470668303541; Mon, 08 Aug 2016 07:58:23 -0700 (PDT) Received: from [192.168.0.98] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id q23sm24156288wme.17.2016.08.08.07.58.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Aug 2016 07:58:22 -0700 (PDT) To: internals@lists.php.net References: Message-ID: Date: Mon, 8 Aug 2016 15:56:11 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Function auto-loading From: rowan.collins@gmail.com (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) !== 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]