Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54627 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35428 invoked from network); 15 Aug 2011 12:34:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2011 12:34:04 -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.214.42 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:60050] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/40-33457-932194E4 for ; Mon, 15 Aug 2011 08:34:02 -0400 Received: by bkd19 with SMTP id 19so3069865bkd.29 for ; Mon, 15 Aug 2011 05:33:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.230.194 with SMTP id jn2mr345758bkb.380.1313411636913; Mon, 15 Aug 2011 05:33:56 -0700 (PDT) Received: by 10.204.115.133 with HTTP; Mon, 15 Aug 2011 05:33:55 -0700 (PDT) In-Reply-To: References: Date: Mon, 15 Aug 2011 08:33:55 -0400 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=485b393ab5890fe6e804aa8a7af6 Subject: Re: [PHP-DEV] [RFC] Function autoloading through spl_autoload From: rasmus@mindplay.dk (Rasmus Schultz) --485b393ab5890fe6e804aa8a7af6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I'm not talking about the __call() magic method, I'm proposing a global and/or namespaced call to a flat __call() *function *- you could use it to implement autoloading like so: * * closure) and loading scripts that return an anonymous function. Similarly, we could use a namespace-specific __call() function as shown above, to autoload functions. It was just a thought - just throwing it out there for discussion, I'm not submitting a complete RFC at this point :-) / Rasmus Schultz On Sun, Aug 14, 2011 at 6:44 PM, Ferenc Kovacs wrote: > On Mon, Aug 15, 2011 at 12:11 AM, Rasmus Schultz > wrote: > > Instead of trying to figure out how to autoload functions and cover all > your > > bases, how about simply adding a __call() magic method? > > > > That way, each application (or framework) can make their own decisions > about > > what they're going to autoload and how. > > > > A much simpler solution, and one with more potential uses than just > > autoloading. > > > > The __call() method could be invoked first in the current namespace, if > > present - then in the parent namespace, if present, etc. up to the glob= al > > namespace. Since functions are no longer just global, but can now exist > in a > > namespace, it is likely you're going to need a different "autoloader" o= r > > other dynamic function resolvers in each namespace, since we tend to > create > > a namespace for classes/functions designed to perform a specific kind o= f > > task - for example, a template/view-engine probably needs to autoload > > display-formatting functions, while a controller/dispatcher might need = to > > autoload action-filters, etc. > > > > Just a thought :-) > > > > / Rasmus Schultz > > > > we already have a magic method with the name __call. > I'm not sure where you propose adding this magic method, but judging > from it's name, you would like to propose something similar than > __autoload what we have abadoned for many reasons, the main reasons is > that the spl_autoload_register is more explicit and supports having > multiple callbacks. > > please create an RFC for your idea, from first glance, I feel that you > didn't really thought over the details yet. > > > -- > Ferenc Kov=E1cs > @Tyr43l - http://tyrael.hu > --485b393ab5890fe6e804aa8a7af6--