Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94942 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4471 invoked from network); 8 Aug 2016 17:06:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Aug 2016 17:06:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.217.170 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.217.170 mail-ua0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:35926] helo=mail-ua0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/45-33134-C1CB8A75 for ; Mon, 08 Aug 2016 13:06:36 -0400 Received: by mail-ua0-f170.google.com with SMTP id 97so28204206uav.3 for ; Mon, 08 Aug 2016 10:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=3kaKcYeH9VTn43VbYx1XUfMIvhQPgqc9BKKg8+aFCso=; b=v77lm7AabxH7QpQYK6eJpd2ablL/eyqdDWkkMZPz3l8FPiyCTBLxc8qw7X1m9HkflU Ko7GdOAbsgLnHsLv9YtcHWVNbkadL6bF+jReH8WDXtJ5cCc9LvmJygFfO8Lf8dwBjWvY RiZ/7uXS+5txu90KEOIaV0ddiok0IfWKGzvGc2ulzrPTFvlznlz7VmMWgNUv624Z88WU EUdtoRf7gg5uIMl/AYhaT+6q3peBBRpdPEwTGSLCHkaNRVbzNtiVAnx+SDvBWSOVsFjP IyhOWEpXuNpdnMoXIyUXAG+v50OGzD4YaWh79DuW+QMGeb8lZQwwFSa3JsLlQzinJqFG vX7w== 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=3kaKcYeH9VTn43VbYx1XUfMIvhQPgqc9BKKg8+aFCso=; b=W1aCI+NyJwRi19G8inxKHweXbGdIfGIz91IV44LaWPOmxWq7GEVinYf3w36lK4hKPJ iuR0MUMdYUU3Ief0TXyStfedLRfwtiA7fjTYrktOMffB/lSybR/Taj4AtKiXDSbIVyvO 8qavd3xX6hz5G9urlP8hFI4JOid8/j2gnCX0ZfLDUjL6KBcqrmvgV/BRKWD2JegrxVEn ueWtgtCcyW7Bbr/7AGpTTzfOg1EqnDvqC5HHc9c+utuGdpu5OPjj2uVzmlKoh7JLmVZj bHnTiZY45o71WgS3d7TaKMpUB7bCY1ydl3E+SaE0mciZxobGbXlKsmNwuqMrQsBvz1X4 p+Lg== X-Gm-Message-State: AEkoousfTGyEmRyed8e4Fjbq3mmhj5exyFCK0Ez7n89rMq2TGtzrvwtkj36pF1heGfvxn/KpkM2X8yC3Wk2Nqg== X-Received: by 10.31.0.133 with SMTP id 127mr4991524vka.57.1470675993934; Mon, 08 Aug 2016 10:06:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.153.195 with HTTP; Mon, 8 Aug 2016 10:06:33 -0700 (PDT) In-Reply-To: <33781781-2a63-78c1-68a1-9e19ad720d8d@gmail.com> References: <33781781-2a63-78c1-68a1-9e19ad720d8d@gmail.com> Date: Mon, 8 Aug 2016 19:06:33 +0200 Message-ID: To: Rowan Collins Cc: internals Content-Type: multipart/alternative; boundary=001a113d9cec32d73b0539927046 Subject: Re: [PHP-DEV] Function auto-loading From: rasmus@mindplay.dk (Rasmus Schultz) --001a113d9cec32d73b0539927046 Content-Type: text/plain; charset=UTF-8 > If not, I don't see why we ever need to be able to autoload global functions Well, for consistency. For one, if you're refactoring a global function to a namespaced one, this inconsistency is going to be surprising. In general, any inconsistency in a language is surprising. Why only non-global functions can autoload, is going to require a longer explanation. And that's bad. If we support auto-loading only for namespaced functions, we're actively favoring (potentially micro-) performance over consistency. I use global functions. I know that's not popular, but it's a language feature, and I use it - for things like test-frameworks and global view helper-functions. Single namespace spanning multiple files is also a case for me - that's not a decision we should make; likely, a PSR and Composer auto-loading features will drive those decisions. One should have the freedom to add a new function to an existing namespace, and make that function auto-load, while packaging that function as a separate optionally-installable package. I can't see the introduction of arbitrary restrictions or limitations leading to anything good, language-wise. 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! On Mon, Aug 8, 2016 at 6:46 PM, Rowan Collins wrote: > On 08/08/2016 17:00, Levi Morrison wrote: > >> 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". >> >> >> They'll say the same when function and class autoloading don't work the >> same way anyway. I think unifying their behavior over time is the best >> solution forward. Yes, I'm talking about a BC break eventually, but the >> suggestion to autoload only fully qualified function names could buy us >> the time to make that BC break less severe. >> > > > Do you mean eventually changing the name resolution rules for functions to > match those for classes? I wasn't around at the time it was discussed, and > if we were adding them now would be tempted to say the leading \ should > always be mandatory, just like it is for classes. But since we have what we > have, I don't see that big an advantage to changing it. > > 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. > > > Regards, > -- > Rowan Collins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a113d9cec32d73b0539927046--