Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94948 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18309 invoked from network); 8 Aug 2016 19:04:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Aug 2016 19:04:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.217 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.217 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.217] ([81.169.146.217:21759] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C8/B7-33134-3C7D8A75 for ; Mon, 08 Aug 2016 15:04:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1470683073; l=7883; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:References:In-Reply-To: MIME-Version; bh=vis7a4K/qDS8yu1dsvSHR2xOsA06/ooqutfEW0jJIvI=; b=L+1TbJaocyaTaRxpb1vxv7OUG40TCJnt+i7Ymxrgl/e0MeQoceEh0kB+2qGZ+v1HUvK BF5wjx4mXFu7VwIaRylKOLbeV1ZBbSgg5eoHa/+SHlBlvPZYwovPClkaPY5yLZ+47E6Y7 XqFR3Gh9tD+47YIWyMwQ2q5gsD0KK4tdAJk= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLGvomb4bl9EfHtOnE6 X-RZG-CLASS-ID: mo00 Received: from mail-wm0-f52.google.com ([74.125.82.52]) by smtp.strato.de (RZmta 38.13 AUTH) with ESMTPSA id j0b65es78J4XFNq (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp384r1 with 384 ECDH bits, eq. 7680 bits RSA)) (Client did not present a certificate) for ; Mon, 8 Aug 2016 21:04:33 +0200 (CEST) Received: by mail-wm0-f52.google.com with SMTP id i5so159234044wmg.0 for ; Mon, 08 Aug 2016 12:04:33 -0700 (PDT) X-Gm-Message-State: AEkooutDdo6sf16LY2Inqc9U1p+4u2OLnXiLH6tyUCT4+Sii8WpqtNiZ2F8f3PvS54/mskSVn480g7PzEYlEbQ== X-Received: by 10.194.63.39 with SMTP id d7mr84434401wjs.13.1470683073145; Mon, 08 Aug 2016 12:04:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.27.206 with HTTP; Mon, 8 Aug 2016 12:04:32 -0700 (PDT) In-Reply-To: References: <33781781-2a63-78c1-68a1-9e19ad720d8d@gmail.com> Date: Mon, 8 Aug 2016 21:04:32 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Rasmus Schultz Cc: Rowan Collins , internals Content-Type: multipart/alternative; boundary=047d7ba97ce026fb0305399416a3 Subject: Re: [PHP-DEV] Function auto-loading From: me@kelunik.com (Niklas Keller) --047d7ba97ce026fb0305399416a3 Content-Type: text/plain; charset=UTF-8 2016-08-08 19:06 GMT+02:00 Rasmus Schultz : > > If not, I don't see why we ever need to be able to autoload global > functions > > Well, for consistency. > Not only for consistency, but also for things like polyfills, e.g. random_compat. Regards, Niklas > 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 > > > > > --047d7ba97ce026fb0305399416a3--