Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40697 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49288 invoked from network); 26 Sep 2008 04:36:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Sep 2008 04:36:12 -0000 Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 76.96.62.48 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 76.96.62.48 qmta05.westchester.pa.mail.comcast.net Received: from [76.96.62.48] ([76.96.62.48:38517] helo=QMTA05.westchester.pa.mail.comcast.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B6/85-19781-CB66CD84 for ; Fri, 26 Sep 2008 00:36:12 -0400 Received: from OMTA12.westchester.pa.mail.comcast.net ([76.96.62.44]) by QMTA05.westchester.pa.mail.comcast.net with comcast id K1Lj1a0030xGWP855Gc9HM; Fri, 26 Sep 2008 04:36:09 +0000 Received: from earth.ufp ([24.13.255.226]) by OMTA12.westchester.pa.mail.comcast.net with comcast id KGc91a0054trKQ83YGc9RH; Fri, 26 Sep 2008 04:36:09 +0000 X-Authority-Analysis: v=1.0 c=1 a=pqr65HgrOi9EIynFInQA:9 a=LXeghT_0n-ABPbIQpBoA:7 a=GvNKOAMG5OSkoYnDQlbi19Nl3wcA:4 a=QQO4ek00_mEA:10 a=FHBbIDN7CdwA:10 a=LY0hPdMaydYA:10 Received: from localhost (localhost [127.0.0.1]) by earth.ufp (Postfix) with ESMTP id 336B4D7A20 for ; Thu, 25 Sep 2008 23:36:09 -0500 (CDT) Received: from earth.ufp ([127.0.0.1]) by localhost (earth.ufp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Kj9r-HZZNSTy for ; Thu, 25 Sep 2008 23:36:08 -0500 (CDT) Received: from luna (unknown [192.168.42.1]) by earth.ufp (Postfix) with ESMTPSA id 20B29D7A15 for ; Thu, 25 Sep 2008 23:36:07 -0500 (CDT) To: internals@lists.php.net Date: Thu, 25 Sep 2008 23:36:05 -0500 User-Agent: KMail/1.9.9 References: <48D7F5EF.3090202@zend.com> <200809222239.07319.larry@garfieldtech.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200809252336.05332.larry@garfieldtech.com> Subject: Re: [PHP-DEV] namespace issues From: larry@garfieldtech.com (Larry Garfield) On Thursday 25 September 2008 9:08:27 am Lukas Kahwe Smith wrote: > > No, namespaces for functions can most certainly *not* be emulated > > with either > > variable functions or static methods. Dropping namespace support for > > functions makes namespaces mostly useless for anyone who is not 100% > > OOP. > > There's no reason to make functions second-class citizens (no pun > > intended). > > sure point taken on the monolithic files, when sticking different > functions into classes just for the sake of them then becoming > namespaceable. but how would allowing functions in namespaces solve > this issue? > > regards, > Lukas Kahwe Smith > mls@pooteeweet.org Functions in namespaces serve the same purpose as classes in namespaces, for whatever that purpose is this week. :-) It allows for shorter function names for related functions (that cannot be part of the same class for practical architectural reasons, as mentioned, or for conceptual reasons) and for clustering of functionality in ways that classes are ill-suited for. Another advantage is for differentiation. One problem we have run into in Drupal is that if we have a function named "foo_bar_baz()", is that the "bar_baz()" function of the "foo" module/namespace or is it the "baz()" function of the "foo_bar" module/namespace? (We are trying to implement some performance enhancement logic that depends on knowing the difference between those two case.) Note that we cannot forbid such modules/namespaces as anyone can write a module named whatever they feel like. In theory we could use a double underscore, foo__bar_baz(), but that's just as silly as class Zend_Controller_Factory_View_Plugin_Thing. Ideally we could do foo::bar_baz(), eliminate the ambiguity, and make it easier for module developers, too. Just define your module as a namespace and then you always have a function bar_baz() inside it. And we can continue to split modules across multiple files (absolutely critical for performance) and allow modules to define functions on behalf of another module (absolutely critical for functionality). See the sample code I posted back on 9/9 in response to your request for implementations. My point in the GP post is that "you can just use static methods" to emulate namespaces for functions is wrong, and cannot be used as an argument that functions do not need or should not get namespaces. -- Larry Garfield larry@garfieldtech.com