Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94914 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47567 invoked from network); 8 Aug 2016 10:53:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Aug 2016 10:53:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; 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:37553] helo=mail-wm0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/7A-33134-7B468A75 for ; Mon, 08 Aug 2016 06:53:43 -0400 Received: by mail-wm0-f45.google.com with SMTP id i5so130359767wmg.0 for ; Mon, 08 Aug 2016 03:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=n60UqZtybd3/jbfjRNGpce19/UgXRXdEjyx75lolINw=; b=VJkgqtAFeAWC+cfg4x4VdmJqlRj6h4exL1amDeq9o+9LGtyZdYybKOWqoT6U9aW3ne 2dOknfk0ShTrOPo5Z6C54LfvR8jzBq3ql7T1S4QL1zsl0JkN1ATMSYGpfSBXfqfherT3 sTGADIFvxRj7/l2ZCBnQGANv+oV9sevnB8Uw5u21b1s9MR1Q4wxS22StZi3XAGo0DLEX orXtORPkOqkUxlR817HCmoCM8gWBFg4AalJWA/9dSZDyH2l+WTk3DRn4+n8CZYxHYE1h Wpj1B8EAEn3eXicoBCD6x/p4ak7HN9Dn7hixwP/7WAiwzG9E8LBkZZ4JCGGJVNjrfGq7 lzOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=n60UqZtybd3/jbfjRNGpce19/UgXRXdEjyx75lolINw=; b=QnHW3M37YVk31+bv3qQIKa0d8RST9SjDT9S2zIEbHKYjAqsT0CrhA5dArJflwkcPvb WmJPwx2yATfIoFgz2ZOxZmmyRB/JW9TxzgdslYC9OlA7dxxwtE6k6ms9wLsvbjtDUf7e 1sMxwgw+Fbyv2lohHxQDe7ee6lttgUHFRapQjnzJ13etoCpOu+yL3tl/Po3j8hgL90On A32VdSVEqZyP9Jt/j4E1i7EzZh6fpj116Z+vmeEV6uZQsMPp0WxIKktLw7EQsPTfadNk k8324UY3icg4+imXsHu9HUUeNdDIpciKTpknQUks1x9IQ88835lH4LfiFCG5qFKBGKUV KeDw== X-Gm-Message-State: AEkoouuRTLHFWTHceFSp2DGTWbvEy0vQZz7nMT0ojwYJMU4XXGoXtAikJhvcmvD1w1pucQ== X-Received: by 10.28.32.15 with SMTP id g15mr14657900wmg.25.1470653618640; Mon, 08 Aug 2016 03:53:38 -0700 (PDT) Received: from [192.168.0.98] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id bw9sm32318702wjc.33.2016.08.08.03.53.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Aug 2016 03:53:37 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <6600076c-d046-bdca-f339-79894781a996@gmail.com> Date: Mon, 8 Aug 2016 11:51:27 +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: 8bit Subject: Re: [PHP-DEV] Function auto-loading From: rowan.collins@gmail.com (Rowan Collins) On 07/08/2016 23:42, Davey Shafik wrote: > Perhaps the solution is to look at this as a forward-only feature, rather > than a backfill. > > We only support autoloading for unambiguous names — if you want the > autoloader to be called, either > import the function with use, or use a [fully] qualified name. > > This should remove the ambiguities and performance concerns. I actually quite like this suggestion, because it fits with the use case I see as being most common: replacing static-only classes with a namespace of related functions. (Remember that "static classes" were rejected at RFC in favour of exactly this.) To be clear, the case we'd be "refusing" to autoload (other than global functions themselves) would be a function in the *exact* current namespace: namespace Acme\Foo\Bar; do_something(); // won't autoload But that only matters if namespace "\Acme\Foo\Bar" is split over multiple files. In this case, the declaration of "Acme\Foo\Bar\do_something()" would probably be in the same file anyway, so not need autoloading. Given that we have hierarchical namespaces, this seems a more likely scenario: namespace Acme\Foo\Bar; // function autoload for 'Acme\Foo\Bar\Utilities\do_something' Utilities\do_something(); Or importing as an alias: namespace Acme\Foo\Bar; use Acme\Stuff\Utilities as Util; // function autoload for 'Acme\Stuff\Utilities\do_something' Util\do_something(); Note that an unqualified function call "do_something()" already doesn't look in any imported namespaces, so "use Acme\Stuff\Utilities;" doesn't do anything to function name resolution. So we would be defining a simple rule: "the function autoloader will be called at run time for any namespace-qualified function name which is not already defined". This feels like a better compromise than an autoload cache, because I can see the invalidation rules getting messy, and heavily-used global functions still firing the autoloader for many different possible prefixes. Regards, -- Rowan Collins [IMSoP]