Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:15745 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37434 invoked by uid 1010); 3 Apr 2005 12:18:37 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 37419 invoked from network); 3 Apr 2005 12:18:36 -0000 Received: from unknown (HELO hristov.com) (127.0.0.1) by localhost with SMTP; 3 Apr 2005 12:18:36 -0000 X-Host-Fingerprint: 80.168.8.116 iko.gotobg.net Linux 2.4/2.6 Received: from ([80.168.8.116:42941] helo=iko.gotobg.net) by pb1.pair.com (ecelerity HEAD r(5268)) with SMTP id 5B/68-19272-B1FDF424 for ; Sun, 03 Apr 2005 08:18:35 -0400 Received: from p54a0d339.dip.t-dialin.net ([84.160.211.57] helo=[192.168.0.41]) by iko.gotobg.net with esmtpa (Exim 4.43) id 1DI43k-0002Qp-Nz; Sun, 03 Apr 2005 15:18:33 +0300 Message-ID: <424FDF15.5040100@hristov.com> Date: Sun, 03 Apr 2005 14:18:29 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b2) Gecko/20050219 MIME-Version: 1.0 To: Zeev Suraski CC: internals@lists.php.net References: <5.1.0.14.2.20050403125628.03f83de0@localhost> In-Reply-To: <5.1.0.14.2.20050403125628.03f83de0@localhost> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iko.gotobg.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] __autoload() enhancement From: php@hristov.com (Andrey Hristov) Zeev Suraski wrote: > All, > > One problem that became apparent after the introduction of __autoload(), > is that different pieces of code, sometimes coming from different > sources, may want to declare this function in a different way. Today, > __autoload() is treated like any other function, so it's impossible to > re-declare it. > > Marcus tried to solve it by introducing an __autoload() wrapper in SPL. > Personally I think it's probably not the right way to go, but that's > beside the point right now. > > What I'd like to suggest is a change in the behavior of __autoload(), so > that multiple __autoload()'s could be defined. Essentially, declaring > __autoload() would in fact add the function to the list of functions > that are called in case a missing class is referenced. However, it will > not actually place a function named __autoload() in the PHP function > table. That way, it would be possible to declare multiple > __autoloads(), and have all of them called when a missing class is spotted. > > The two issues with this solution are: > > 1. It will be impossible to use the standard means to determine whether > __autoload() is declared or not. I don't think that's a very important > issue but it's there nonetheless. > 2. We need to determine what makes sense as far as calling order if we > have more than one __autoload(). My guess would be calling them in the > order they were registered, and checking whether the class was defined > after each one (if it was - stop). > > That solution maintains downwards compatibility (almost, other than > issue #1). > > Thoughts? > > Zeev > Hi Zeev, the idea one __autoload() may not be capable of loading therefore the next one in the chain should be executed to try to load/define the needed code. bool(false) returned from __autoload() means try with the next in the chain, bool(true) everything went fine skip the rest of the queue. Andrey