Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101804 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22980 invoked from network); 7 Feb 2018 17:19:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Feb 2018 17:19:31 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.47 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.47 mail-wm0-f47.google.com Received: from [74.125.82.47] ([74.125.82.47:53529] helo=mail-wm0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 31/0F-49805-3253B7A5 for ; Wed, 07 Feb 2018 12:19:31 -0500 Received: by mail-wm0-f47.google.com with SMTP id t74so4583131wme.3 for ; Wed, 07 Feb 2018 09:19:31 -0800 (PST) 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; bh=99rjHvFnfzHLcDdAIvSvTBJZrwjtu46OiL2IXvsjNtI=; b=HoMReV4wz6sV+rJxgaCfVnOqEvOcmoL3TP5I8t68OTjPj1iwYecueFoMZPR2Xe6cmC bwJQPYdm4RQZTQNMF4uM6jSrz2SDNSNxHMjY0OYV5N4CCqjNAnliAmK4/ioZ3p8PJyi9 M6HvKExjSY3QMl22Uz+uoJaCrU8WF1BNxRZmxJIGhf+YLNqH8kllmuy046cS441ihfQE 2jfo1IrTIXWN1hRkhHRdc5EOEiRjhtNaJ07xPhdkbnWgzAzsVfEKQzEzZttBz8sldazK oRGNz799vshpew2ecSenIxZ3F1Wd+Ev2icYieuVtanKTtEy2V08XLno8KlPbx9QcqtUj NFkg== 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; bh=99rjHvFnfzHLcDdAIvSvTBJZrwjtu46OiL2IXvsjNtI=; b=LtVHXWZTMXKOZFY/0b9n07vaiofiVaEs5RvsAfUlFoRWKM+oZ1oUcjANxU5Dbd7ft2 iB2DKvguIa917dkCg8Q3PtvGadz/s3cVJgKM38t33355QG6SyQU2nblqWCwmeu17/eKc NqHCQIwilYt4+A8avMEKRVWQC/uWS8+bVShgi8M+FsB8FpTcWUCEm2zK94DkUbIHUq+O Dgnk71B/fP3vit1CTMQs9tPSPMmFq8tZl8QKRk1zGu2tAUkAV2JZ9dRUvMx5UyoJoSO5 TE9F8b5Mp/Age5VfaebfENI0+KbhPvMEXxKcTTG3nIbnJMOGnVoBNFD9znTkDl9DBsKr 5S0g== X-Gm-Message-State: APf1xPB1aUstLxXcLJ1F2ZLbE4RhU9z7ZfzqEIrG88K5ZMDV/b3VJAb/ R3OJvaH8tLCjzPK6Gde8alTc7TJSc85h5oZjI23dhw== X-Google-Smtp-Source: AH8x224oO1QmvYX0xot9gVeX75pQ2q/vSEig0xseL7MPfuWYL7MsnBJX+yTBCuGkza1xMY9bdCa5lmbH4ynxYeoXF1M= X-Received: by 10.80.194.146 with SMTP id o18mr9398179edf.67.1518023967638; Wed, 07 Feb 2018 09:19:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.222.195 with HTTP; Wed, 7 Feb 2018 09:19:26 -0800 (PST) In-Reply-To: References: Date: Wed, 7 Feb 2018 17:19:26 +0000 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="94eb2c1ccc905a09720564a27f50" Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Deprecation of fallback to root scope From: rowan.collins@gmail.com (Rowan Collins) --94eb2c1ccc905a09720564a27f50 Content-Type: text/plain; charset="UTF-8" On 7 February 2018 at 16:56, Andrey Andreev wrote: > Hi, > > What's not obvious (to me at least) here is why is the current > behavior preventing a ("sensible", as the RFC desribes it) > implementation of function autoloading? That seems to be a major > motivation factor for the proposal, yet doesn't seem to be explained > anywhere. > It's not been mentioned explicitly in this thread, but has come up a lot in previous discussions. I'll attempt to summarise my understanding. Currently, when you write "foo()" in code marked as namespace "Bob", the engine does this: 1. Check for a function "Bob\foo", use it if defined 2. Check for a function "foo", use it if defined 3. Raise an error if neither is defined If we add autoloading of functions, the logical sequence would be to attempt the autoloader every time we encounter something not defined: 1. Check for a function "Bob\foo", use it if defined 1a. Run autoloader callback for "Bob\foo"; use function if one is now defined 2. Check for a function "foo", use it if defined 2a. Run autoloader callback for "foo"; use function if one is now defined 3. Raise an error if neither is defined The problem is that all of this has to happen *every time you call the function*, because at any time, the function could be registered, or a new autoloader registered that knows where to find it. If "foo" is actually a global function, that means steps 1 and 1a will be run every time your use of "foo()" is reached, meaning that every call has an additional overhead of calling the autoloader callback. Since the autoloader callback might in fact be a whole stack of registered closures, this means a significant overhead every time you mention any global function, which includes 90% of PHP's standard library. I hope that clarifies the general problem (and that I haven't made any mistakes in my explanation). Regards, -- Rowan Collins [IMSoP] --94eb2c1ccc905a09720564a27f50--