Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25632 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82456 invoked by uid 1010); 12 Sep 2006 11:02:42 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 82441 invoked from network); 12 Sep 2006 11:02:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Sep 2006 11:02:42 -0000 Authentication-Results: pb1.pair.com header.from=francois.laupretre@ratp.fr; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=francois.laupretre@ratp.fr; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain ratp.fr from 81.255.174.9 cause and error) X-PHP-List-Original-Sender: francois.laupretre@ratp.fr X-Host-Fingerprint: 81.255.174.9 unknown Solaris 8 (2) Received: from [81.255.174.9] ([81.255.174.9:49750] helo=odii-smtp.ratp.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 14/4B-02095-0D396054 for ; Tue, 12 Sep 2006 07:02:42 -0400 Received: from bl03ic06.info.ratp (unknown [188.20.209.10]) by odii-smtp.ratp.fr (Postfix) with ESMTP id 59DD511F77E; Tue, 12 Sep 2006 13:02:36 +0200 (MEST) Received: from EXCHANGE04.info.ratp ([188.20.209.4]) by bl03ic06.info.ratp with Microsoft SMTPSVC(6.0.3790.211); Tue, 12 Sep 2006 13:01:53 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Tue, 12 Sep 2006 13:01:12 +0200 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Re: Re: __autoloading and functions Thread-Index: AcbWWsJrkftt9lQvSdCbEjWGJje3ug== To: , X-OriginalArrivalTime: 12 Sep 2006 11:01:53.0951 (UTC) FILETIME=[DB31C2F0:01C6D65A] Subject: Re: Re: __autoloading and functions From: francois.laupretre@ratp.fr (=?iso-8859-1?Q?LAUPRETRE_Fran=E7ois_=28P=29?=) Yes, the trivial answer is to name each file after the symbol it = contains, but it limits to one symbol per file (and I was talking about = autoloading constants ! :-). Once again, if we don't propose a smarter autoload manager, extending = the autoload feature to functions is not very interesting because, for = most PHP programmers, it won't make their task easier (and it won't = allow to autoload extensions, which would be a big step forward). I would be glad if people interested in this subject could have a look = at an autoload manager I have written and which could, IMHO, solve most = of these problems. It contains two parts : a CLI program to scan source = files and extensions and store their symbols in map files, and a runtime = resolver which will use these files. A map file can contain symbols for = any number of source or extension files allowing, for instance, to put = only one map file in the extensions directory to store the symbols of = every extensions present on the host. As there is no hook at this time in the PHP engine to autoload functions = and constants, their resolutions must be explicitely requested before = using the symbol but, if the autoload feature was extended to these = symbol types, the autoloader would be completely transparent to the = client programs. Of course, it is written in PHP today but it would be quite easy to = rewrite it in C and integrate it to the core. If it was integrated to the core and if we added a cache to keep symbol = maps in memory, I am sure that the speed up due to JIT loading would = balance the autoloading overhead. Please tell me what you think about it. Regards Fran=E7ois Terje Sletteb=F8 wrote: > > > In either of the above cases, you specify where a function = belongs, both > > > where it's defined, and where it's used (either through full > qualification, > > > or a shorter one, using "import"). I'm not arguing for a function = to > > > "magically" become a part of a class/module/whatever, if you = thought so > > > > > Then the question is how do you think this function would be used? >=20 > That's a very good question... One "simple" answer would be to have = one file > per function, and have it work like typical class autoloaders. = However, that > could be too much overhead (on many levels), having a lot of small = files, > that conceptually belong together. >=20 > Maybe function autoloading isn't such an obvious feature, after all = (which > was one reason for bringing it up - getting the pros and cons of it. = By the > way, I've now also read in on the archive of this and the other issues > having been mentioned in this thread, such as namespaces). >=20 > Regards, >=20 > Terje