Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50884 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6190 invoked from network); 7 Dec 2010 04:43:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Dec 2010 04:43:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 76.96.62.80 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 76.96.62.80 qmta08.westchester.pa.mail.comcast.net Received: from [76.96.62.80] ([76.96.62.80:41721] helo=qmta08.westchester.pa.mail.comcast.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 26/F5-59654-17BBDFC4 for ; Mon, 06 Dec 2010 23:43:29 -0500 Received: from omta14.westchester.pa.mail.comcast.net ([76.96.62.60]) by qmta08.westchester.pa.mail.comcast.net with comcast id g46D1f0061HzFnQ584jTiu; Tue, 07 Dec 2010 04:43:27 +0000 Received: from earth.ufp ([98.220.236.211]) by omta14.westchester.pa.mail.comcast.net with comcast id g4jT1f0034aLjBW3a4jT0w; Tue, 07 Dec 2010 04:43:27 +0000 Received: from localhost (localhost [127.0.0.1]) by earth.ufp (Postfix) with ESMTP id 9BFA6D7A69 for ; Mon, 6 Dec 2010 22:43:25 -0600 (CST) Received: from earth.ufp ([127.0.0.1]) by localhost (earth.ufp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YaJlcLuSLWgd for ; Mon, 6 Dec 2010 22:43:25 -0600 (CST) Received: from linux-nkec.site (unknown [192.168.42.1]) by earth.ufp (Postfix) with ESMTPSA id 825C0D7A65 for ; Mon, 6 Dec 2010 22:43:25 -0600 (CST) To: internals@lists.php.net Date: Mon, 6 Dec 2010 22:44:16 -0600 User-Agent: KMail/1.13.5 (Linux/2.6.34.7-0.5-desktop; KDE/4.4.4; x86_64; ; ) References: <4CFD4131.8070300@php.net> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-ID: <201012062244.16530.larry@garfieldtech.com> Subject: Re: [PHP-DEV] RFC __autodefine / spl_autodefine From: larry@garfieldtech.com (Larry Garfield) On Monday, December 06, 2010 6:59:08 pm Ross Masters wrote: > Hi Sebastien, > > > __autoload() should die (as in get deprecated ASAP and later removed) > > I couldn't find anything about your opinions on this so I was wondering if > you could elaborate. Do you consider autoloading as a bad practice or just > that spl_autoload_register should be used to add relevant > functions/closures? __autoload() works fine if you have exactly one implementation for your entire system with exactly one set of logic for how to map a class name to a file name. As soon as you try to mix two different libraries together, fatal error. spl_autoload() does not suffer from this short-sighted problem but accomplishes the same goal in a much more robust fashion. Any new meta-auto-load mechanism should forego the dead-end that is a single unique __auto*() function and just use a design that actually works, aka spl_autoload() or similar. With that said, I like the idea of generalizing autoload to include functions et al. Autoloading functions would make my life a lot easier. :-) To be fair, though, half of the potential benefits the OP listed are already solved by using a version control system. Any version control system. If you're still having collisions at the file level when two people work on the same file it's because you're an idiot and are not using version control (or the changes touch each other, in which case this proposal wouldn't help you anyway). The main advantage of this proposal would be lazy-loading of functions. I don't think autoloading methods makes any sense since classes cannot be split between files anyway. I'm not entirely sure what else is actually reasonable to autoload. Classes, Interfaces, Functions, and Traits make up the scope of first-class code structures, don't they? Autoloading a variable doesn't even make sense to me, and include files are already handled by include[_once]. --Larry Garfield