Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32973 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8982 invoked by uid 1010); 24 Oct 2007 19:41:02 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 8967 invoked from network); 24 Oct 2007 19:41:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Oct 2007 19:41:02 -0000 Authentication-Results: pb1.pair.com header.from=chuck@horde.org; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=chuck@horde.org; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain horde.org designates 66.92.78.250 as permitted sender) X-PHP-List-Original-Sender: chuck@horde.org X-Host-Fingerprint: 66.92.78.250 dsl092-078-250.bos1.dsl.speakeasy.net Received: from [66.92.78.250] ([66.92.78.250:35272] helo=technest.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/68-47805-DCF9F174 for ; Wed, 24 Oct 2007 15:41:02 -0400 Received: by technest.org (Postfix, from userid 33) id A21897F00D; Wed, 24 Oct 2007 15:40:58 -0400 (EDT) Received: from ip65-47-144-166.z144-47-65.customer.algx.net (ip65-47-144-166.z144-47-65.customer.algx.net [65.47.144.166]) by technest.org (Horde Framework) with HTTP; Wed, 24 Oct 2007 15:40:58 -0400 Message-ID: <20071024154058.59923y3f6gjdw62o@technest.org> Date: Wed, 24 Oct 2007 15:40:58 -0400 To: internals@lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Internet Messaging Program (IMP) H3 (4.2-cvs) Subject: Autoloading namespace constants and functions From: chuck@horde.org (Chuck Hagenbuch) A few different proposals have mentioned the possibility that import =20 or use statements might trigger autoload. My initial reaction is that this would be bad, BUT: it could let us =20 use autoload to handle namespaced function libraries and namespace =20 constants also - as long as they were imported. Which would be good. The missing piece would be allowing autoload to trigger when a =20 fully-qualified name was used whether that name was for a function, =20 class, or constant. In other words, I'd like autoload to kick in when I do this: ... but let do_stuff be a function in the My::Namespace namespace, not =20 a class method of the Namespace class in the My namespace. Right now as far as I can see autoload will trigger for this =20 situation, but it will fail because after autoload finishes because =20 My::Namespace wasn't declared as a class. Same for accessing namespace =20 constants. Would it be possible to, after autoload runs, go back to seeing if the =20 call is now resolvable, rather than assuming that a class had to be =20 loaded? To try and fend off any "just don't use autoload" responses, the =20 reason I want this to work is that if I can organize my libraries in a =20 way that they are autoloadable, I can leave the decision on how code =20 should be included up to the top-level application using the library. =20 I can use an autoloader with development or when building a site, and =20 then I can start including files explicitly - with no conditional =20 includes and no _once usage - in a very opcode-cache friendly way, =20 with no changes to the libraries or the rest of the app. I think =20 that's a very desirable situation, and namespaces almost get us there =20 - I just can't make full use of namespaced functions or namespace =20 constants right now if I want to do it. -chuck