Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94537 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18278 invoked from network); 17 Jul 2016 23:28:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jul 2016 23:28:22 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.41 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.220.41 mail-pa0-f41.google.com Received: from [209.85.220.41] ([209.85.220.41:36474] helo=mail-pa0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 14/AB-31884-3941C875 for ; Sun, 17 Jul 2016 19:28:20 -0400 Received: by mail-pa0-f41.google.com with SMTP id pp5so47992807pac.3 for ; Sun, 17 Jul 2016 16:28:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=byHLemD+icO4tpjciGETgtEJlTkPfmkaeYVSMvYA7YM=; b=nU8NJq2GbOGSqCIy0FBhFMphvxd8106tasQeTKkBOT+7mnGjXLhplJm4wdFIxfWUVB GZaEbSRYlJO/Y/AqDRd0QLRYOAsSXtsr8EwZQ3ZMU/4xw28pVrtWhpcZSr/3va6hsInl L0Z6KdI4Qh4VqB7aoqkWOfmE3sdr+Dd9MX0ww5MbzlXW1hI5l+BTk1FtfEIrw0iSlPNH UQNR1cCmbJ1A6cwui5gnINoei9w/Ep98781Lb3guIkGDI7RWzXZLUW4Pd97/D/31+n/5 8SUgaVHK2yffvr4pBW7OGfh26M8atb8Ajzb3A9Q0OtCh3jD4BGTiMtScpp36DK0f7l8Z bhqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=byHLemD+icO4tpjciGETgtEJlTkPfmkaeYVSMvYA7YM=; b=RD3/wpwACDYFb25u4qIVsqfTUUFOn8DopZW/xu2RswK8dYp5G+wDJlU4QpuXoa2u5k sDOc21fdWT6I6EkK2y1dQkxRBthwOlLcr5ZLQ/K4w702WTWLWqjF2Ncf1Yi6PUzNlsSl z9aO3pcYwMTCv0UIoWxTANNwOQ/KfdGHb3fLwVGD2hZXzTy1vX1h8JKycm5B2t6emBCX +93A57Tugifjq1qVlErcnPg+pEK0lRjfz2R2M8nIkEKsyY/bc13Je6SfmEgGCR4vMeJt qnLMqW1ZkjQRZQv8GPSj+Y5yfJbZnW0rozS/BTvyzaJ53TAxFJC85yeqctEQaaLxuNPH p0EQ== X-Gm-Message-State: ALyK8tIsWZasvFy56z5J+WxhF0i/5rlpDD92x14DrjZXDacKppnLtWBvnVjREaoILD4TtCJ5wcO7YtjystsSWQ== X-Received: by 10.66.62.226 with SMTP id b2mr51474996pas.119.1468798097052; Sun, 17 Jul 2016 16:28:17 -0700 (PDT) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.66.24.42 with HTTP; Sun, 17 Jul 2016 16:28:16 -0700 (PDT) In-Reply-To: References: Date: Sun, 17 Jul 2016 17:28:16 -0600 X-Google-Sender-Auth: ie89vzzxvA56TZiGTxr6wRHqL9I Message-ID: To: Nikita Popov Cc: Rowan Collins , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Idea: Function autoloading using dummy namespaces From: levim@php.net (Levi Morrison) > 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 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.