Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54669 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97042 invoked from network); 18 Aug 2011 01:49:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Aug 2011 01:49:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=johncrenshaw@priacta.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=johncrenshaw@priacta.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain priacta.com designates 64.95.72.241 as permitted sender) X-PHP-List-Original-Sender: johncrenshaw@priacta.com X-Host-Fingerprint: 64.95.72.241 mxout.myoutlookonline.com Received: from [64.95.72.241] ([64.95.72.241:11048] helo=mxout.myoutlookonline.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1F/B6-56760-0CF6C4E4 for ; Wed, 17 Aug 2011 21:49:52 -0400 Received: from mxout.myoutlookonline.com (localhost [127.0.0.1]) by mxout.myoutlookonline.com (Postfix) with ESMTP id A4E08794B80; Wed, 17 Aug 2011 21:49:49 -0400 (EDT) X-Virus-Scanned: by SpamTitan at mail.lan Received: from HUB016.mail.lan (unknown [10.110.2.1]) by mxout.myoutlookonline.com (Postfix) with ESMTP id 5BA4C794B4C; Wed, 17 Aug 2011 21:49:49 -0400 (EDT) Received: from MAILR001.mail.lan ([10.110.18.27]) by HUB016.mail.lan ([10.110.17.16]) with mapi; Wed, 17 Aug 2011 21:49:49 -0400 To: Stas Malyshev , Matthew Weier O'Phinney CC: "internals@lists.php.net" Date: Wed, 17 Aug 2011 21:49:43 -0400 Thread-Topic: [PHP-DEV] [RFC] Function autoloading through spl_autoload* Thread-Index: AcxdNq9j3wslS2YeSNeb0H3N9ORLYAADZeSA Message-ID: References: <4E481136.3090508@sugarcrm.com> <4E483284.4010100@googlemail.com> <4E4838E1.3000006@sugarcrm.com> <4E48430D.6070409@googlemail.com> <4E486A50.4010700@sugarcrm.com> <4E48A22E.1040900@googlemail.com> <4E48AD3E.6010801@sugarcrm.com> <4E48C126.50707@sugarcrm.com> <4E48D848.1070407@sugarcrm.com> <81.F0.56760.0263C4E4@pb1.pair.com> <4E4C50A7.4000604@sugarcrm.com> In-Reply-To: <4E4C50A7.4000604@sugarcrm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: RE: [PHP-DEV] [RFC] Function autoloading through spl_autoload* From: johncrenshaw@priacta.com (John Crenshaw) > -----Original Message----- > From: Stas Malyshev [mailto:smalyshev@sugarcrm.com]=20 > Sent: Wednesday, August 17, 2011 7:37 PM > To: Matthew Weier O'Phinney > Cc: internals@lists.php.net > Subject: Re: [PHP-DEV] [RFC] Function autoloading through spl_autoload* > > Hi! > > On 8/17/11 2:44 PM, Matthew Weier O'Phinney wrote: > > There's nothing saying you can't have the exact same situation right no= w > > with classes and autoloading, too. > > Well, there is something - the "file per class" custom which is followed= =20 > quite widely. > > And also classes don't have fallbacks, while the functions do. > > > While I understand your objections, I think that after the functionalit= y > > exists, there can be discussions about best practices -- e.g., putting > > one function per file when autoloading, or documenting when all > > I'm not sure anybody would really do function-per-file - it's too tedious= . > > --=20 > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 Tedious, and slow because the overhead for each file loaded can easily be i= n the 2-5ms range. Nobody is going to have a function per file, but they ar= e still likely to use function autoloading in other ways. A likely case for= this would be to autoload a group of functions that all share the same pre= fix. Another case might be to autoload a set of functions that are related = to something else (for example, usability of singleton classes would benefi= t greatly from having a function of the same name as the class, or classes = may want to provide a factory function of the same name.) John Crenshaw Priacta, Inc. P.S. Before someone flames me about the evilness of singletons, yes, I know= ; but, occasionally they still have a place. There is usually only one sess= ion, there is only one app, there is usually only one database, logging is = usually configured globally, etc.