Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94539 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21594 invoked from network); 17 Jul 2016 23:55:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jul 2016 23:55:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.174 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.161.174 mail-yw0-f174.google.com Received: from [209.85.161.174] ([209.85.161.174:36153] helo=mail-yw0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A4/5C-31884-1EA1C875 for ; Sun, 17 Jul 2016 19:55:13 -0400 Received: by mail-yw0-f174.google.com with SMTP id c124so19719397ywd.3 for ; Sun, 17 Jul 2016 16:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=WdRyQX+cueISpK+HNW8eQfhszNKcZruQEfCgIQkt1xQ=; b=KbcEzTivofZKuCkYqU6iukyQCBIgSSa4VXZv61WzyI/IzhSHAJiIN04PSTvie+d2sg FGPkykTdjYK3eqHPZgGh4qhE2oGPCXkYim6y8K9NMg09VMkrKL7JboRuyh5Z4zwX/yzM IziVU4unksbFr2iV40EJItgOHWdd2ikskrPFKyr5TUS9+6pGV86BpO6AeJaYUhMwKGHe dbrq50mgA6anCiDrOOoU2xKpj5wA9YzclmN3oKETxV78IsJ0pK741jwQi1A53jhubc6M ihJSLYsja9LoDMOlEjnwAFLKXBq92nfp43yzVeRvrx5Xto22Jltro3OnlEiTTxUXTeHT SobA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=WdRyQX+cueISpK+HNW8eQfhszNKcZruQEfCgIQkt1xQ=; b=eIgQgnF/2amlrHKfqpnNiuOFitlzAd46RTohMHAJeeBTOPlMpkCJpUihFbFQqnwnZP jqA3WmF6D8yZ8tSuOYYbR7exW1+nfExDO62pqof65NVKzwOvc5L+tchYPVXtQWKEEccm yLdvPS24QLfnzYLqHoLhAZm6OXYleqNZw1u2z2j2qLK8pAv7ZBgHTthauKHkmldeUMih RHLVzEdwkqT6TiiprFEXp6J7jBCDpYGnsb+mVD9L6EnKRocSGgpuAsryjtZS4VYzt+59 1SR5+/fWnU9nSR/1d/2vjKM2+JX/Fy/TbvoX/+OxhUEQaI6uVW6lpKmbMOvgEq0O9Kt4 0Iwg== X-Gm-Message-State: ALyK8tJ22XgiiAkRFxp8sQxixdGDg1j3aLu4xCrvzfvCFoZcbCHviNu4RV9WKewYUeTH+3vDbfR/yxOgBXW8HQ== X-Received: by 10.37.20.7 with SMTP id 7mr20539871ybu.45.1468799710473; Sun, 17 Jul 2016 16:55:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.131.129 with HTTP; Sun, 17 Jul 2016 16:55:09 -0700 (PDT) In-Reply-To: References: Date: Mon, 18 Jul 2016 01:55:09 +0200 Message-ID: To: Levi Morrison Cc: Rowan Collins , PHP Internals Content-Type: multipart/alternative; boundary=001a113d3852fd316d0537dd9476 Subject: Re: [PHP-DEV] Idea: Function autoloading using dummy namespaces From: nikita.ppv@gmail.com (Nikita Popov) --001a113d3852fd316d0537dd9476 Content-Type: text/plain; charset=UTF-8 On Mon, Jul 18, 2016 at 1:28 AM, Levi Morrison wrote: > > I don't think this is realistic. > > I'll come back to this one in a moment. > > > As such: > > > > Option B: foo() in namespace Bar will > > a) Check if Bar\foo() exists > > b) Otherwise check if foo() exists > > c) Otherwise try to load 'Bar\foo' > > d) Otherwise try to load 'foo' > > e) If all fails, throw. > > > > This avoids the autoloading overhead when calling functions from the > global > > namespace. However this also means that you cannot autoload a function > with > > the same name as a global function through an unqualified call. > > > > In practice, this is probably less problematic than it might sound, > because > > realistically function autoloading would likely operate on the > > namespace-level rather than the function level, i.e. if one function > from a > > namespace is loaded all of them are, because they are all defined in the > > same file. In such a setting you would never run into this problem as > there > > would be no unqualified calls to functions that have not been loaded yet. > > However, it *would* be an issue if you tried to, say, map each function > to > > a separate file. > > If we are going to use the "one file for all functions" as > justification for defining this behavior a certain way then please > acknowledge it helps both options. One extra autoload from option A is > not a big deal if we are okay with this "one file for all functions" > justification. If we are not okay with that justification then I don't > think option B is viable either. > I don't follow what you mean here. The problem is not the case where the unqualified call actually refers to a namespaced function. The problem is the case where it refers to a global function (which is also far more likely). In this case option A requires that we invoke the autoloader for each call. A relaxed variant would only invoke the autoloader once for each call, assuming that a function that is not loadable at one time will never become loadable (which is of course a significant restriction). The former variant would be prohibitively slow. The latter is more realistic, but I expect it to have non-trivial performance impact nonetheless. As all of this only applies to the case where the unqualified call refers to a global function, it does not actually matter how you namespace things (single or multiple files). As such, I'm not sure I understand your argument. > I think a better option is to try to solve this in 8 by unifying how > functions and classes (and interfaces and traits) work in namespaces. > Ideally the lookup behavior should be the same and all that differs > are the symbol tables being looked in. > Are you suggesting that we require global function references to be written as fully qualified names? This would be a huge BC break for namespaced code. Regards, Nikita --001a113d3852fd316d0537dd9476--