Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94946 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12541 invoked from network); 8 Aug 2016 17:56:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Aug 2016 17:56:21 -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.45 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.45 mail-wm0-f45.google.com Received: from [74.125.82.45] ([74.125.82.45:37556] helo=mail-wm0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 99/D6-33134-4C7C8A75 for ; Mon, 08 Aug 2016 13:56:20 -0400 Received: by mail-wm0-f45.google.com with SMTP id i5so155568575wmg.0 for ; Mon, 08 Aug 2016 10:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:from:to:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=LqabpjQ4+M8sAMQ7R0kU3XzpkndMUqrplugQuI4ZKWQ=; b=w1NLf1AzGMlnhbEZejfIWwf6nC2fqhB1sNqBBQZJeHEbufyl0eP+BXn8MRCDqVMfxl csiZDSuKM79ZPfWQovUxshvo8KDDX9ZrIGa0iTetbGkOPKL33aGjqtbZiXTUcj2F0igH eD+GuiHG8HvswUDg1zplfuXvRZN9e7SbQWGg7pl4Byzl8cdEBnE4xDJiWYrFCTYhJ1aU UfjMsJXasDhaTCTmhxd8VrqrKdxSOL0QYDdsGKmBdH9Hitg6gbmtpmbR8abL4tR6GrXJ J/jlHRgpm22t83vKZ/NcWdQuFAiMoFHBL1rLPFNh2rWQlBKehzUdTwvAAqYZ8vr/D2Nd GbHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:references:from:to:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=LqabpjQ4+M8sAMQ7R0kU3XzpkndMUqrplugQuI4ZKWQ=; b=RR0sj5B4R2abIGn8+XDJJLH54nCnt3Yj7zpcVFtRSSCgDZQefB9wMesECnuycwOWi1 1T0br0SFutTr3an4T1kN//ed03m6g1e3vg5IvPhB3XtOdBez1ZfFeI5vFNXpIUxdguHN RWCF+PN9aJrDirIrMxW193UtWoeVRFn5+/FOCxP4Ehe0ajIkyRpGjNixdDUVczFAD6+T GHs4EiSWPN0UnHSNWHzPqJ/P5CkpxgFTeV86y90YAvn5nASxWFaKY+5Q1GWjQTiNDMTJ xfzS8SJ2G2rQIJhiRSTipZGBEvCC2nZUpRd/5Ad3SMHO4wojDOq9ADJMV4rkUGVmm3+r IgGA== X-Gm-Message-State: AEkoouuIYpWhoHB/1YGJh6L3RPyzD9FFNvSNImv0pRQzLEFzDfPiYGwzBmikRVQE3Kcp6Q== X-Received: by 10.195.13.18 with SMTP id eu18mr84383326wjd.121.1470678977046; Mon, 08 Aug 2016 10:56:17 -0700 (PDT) Received: from [192.168.0.98] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id m127sm24761507wmm.21.2016.08.08.10.56.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Aug 2016 10:56:16 -0700 (PDT) References: <33781781-2a63-78c1-68a1-9e19ad720d8d@gmail.com> To: internals Message-ID: <1d89ec68-de5e-2670-aed1-f12872c073c3@gmail.com> Date: Mon, 8 Aug 2016 18:54:04 +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 18:03, Levi Morrison wrote: > If not, I don't see why we ever need to be able to autoload global > functions. "You want autoloading? Put it in a namespace." Like I > say, that leaves the very small edge case of a single namespace > spanning multiple files, and an autoloader implementation able to > include one of them when a function is called from another. > > > I'm not sure why you would think a single namespace spanning multiple > files is a "very small edge case". I disagree. Here are some libraries I > am aware of *off the top of my head* that use functions the same > namespace across multiple files: > > * https://github.com/nikic/iter > * https://github.com/lstrojny/functional-php > > As well as several of my personal projects. I do not think this is a > "very small edge case." The "iter" example looks a long way from being autoloadable whatever we supported, but the example of one-function-per-file is definitely relevant, so I stand corrected. After a bit of clicking, I even managed to find a line which would fail to autoload under the proposed limitation: https://github.com/lstrojny/functional-php/blob/master/src/Functional/CompareObjectHashOn.php > return compare_on($comparison, $keyFunction); Although interestingly, at the top of the file there is a (technically unnecessary) "use function Functional\compose;" If there was a "use function Functional\compare_on;" as well, we'd be fine. (The function name would then become qualified at compile time and trigger autoloading at run time.) On 08/08/2016 18:06, Rasmus Schultz wrote: > Unless there's a demonstrated, critical performance issue with > auto-loading of global functions, please, let's not cripple this feature > with inconsistencies from the get-go! Sure, we could try to measure it, but remember that it's not just the engine code that has the extra cost, it will actually call a userland function every time you use a global function from inside a namespace if you don't add a leading "\". That userland function will probably do a bunch of string comparisons before deciding it's not interested, and may even try to stat a file or two. Those are really expensive operations, so I think it's a long way from "micro-optimisation". Unfortunately, function name resolution has this quirk that class name resolution doesn't, so something's got to give. Regards, -- Rowan Collins [IMSoP]