Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40613 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52778 invoked from network); 23 Sep 2008 03:39:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Sep 2008 03:39:15 -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.30.24 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 76.96.30.24 qmta02.emeryville.ca.mail.comcast.net Received: from [76.96.30.24] ([76.96.30.24:33171] helo=QMTA02.emeryville.ca.mail.comcast.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/03-35835-2E468D84 for ; Mon, 22 Sep 2008 23:39:14 -0400 Received: from OMTA11.emeryville.ca.mail.comcast.net ([76.96.30.36]) by QMTA02.emeryville.ca.mail.comcast.net with comcast id J2Sd1a00U0mlR8UA23fBxg; Tue, 23 Sep 2008 03:39:11 +0000 Received: from earth.ufp ([24.13.255.226]) by OMTA11.emeryville.ca.mail.comcast.net with comcast id J3fA1a00A4trKQ88X3fAPn; Tue, 23 Sep 2008 03:39:11 +0000 X-Authority-Analysis: v=1.0 c=1 a=GyLhfW8swSM46p1lALIA:9 a=54G7eh9tmX8veU0tKCbyOdpyYe0A:4 a=FHBbIDN7CdwA:10 a=LY0hPdMaydYA:10 Received: from localhost (localhost [127.0.0.1]) by earth.ufp (Postfix) with ESMTP id D32FDD7A20 for ; Mon, 22 Sep 2008 22:39: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 IA2o-gs3mfXf for ; Mon, 22 Sep 2008 22:39:09 -0500 (CDT) Received: from luna (unknown [192.168.42.1]) by earth.ufp (Postfix) with ESMTPSA id 062E1D7A12 for ; Mon, 22 Sep 2008 22:39:08 -0500 (CDT) To: internals@lists.php.net Date: Mon, 22 Sep 2008 22:39:07 -0500 User-Agent: KMail/1.9.9 References: <48D7F5EF.3090202@zend.com> In-Reply-To: <48D7F5EF.3090202@zend.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200809222239.07319.larry@garfieldtech.com> Subject: Re: [PHP-DEV] namespace issues From: larry@garfieldtech.com (Larry Garfield) On Monday 22 September 2008 2:45:51 pm Stanislav Malyshev wrote: > Hi! > > On the ZendCon, we (Marcus, Elizabeth, Andi and myself) had a talk about > what we'd like to do with namespaces, and we arrived at the following > conclusions, which we propose to implement in 5.3: > > 1. Allow braces for namespaces. So, the syntax for namespaces will be: > a) namespace foo; > should be first (non-comment) statement in the file, namespace extends > to the end of the file or next namespace declaration. > b) namespace foo {} > can appear anywhere on the top scope (can not be nested). > Mixing both syntaxes in one file is not possible. The semantics of both > syntaxes will be identical. To clarify, with syntax B you can do multiple namespaces in one file? I have no objection then. > 2. Simplify resolution order for classes in the namespace: unqualified > names are resolved this way: > a) check "use" list if the name was defined at "use", follow that > resolution b) if not, the name resolves to namespace::name > Consequence of this will be that for using internal class inside > namespace one would need to refer to it either as ::Foo or do use ::Foo > prior to its usage. I am OK with this. > 3. Functions will not be allowed inside namespaces. We arrived to > conclusion that they are much more trouble than they're worth, and > summarily we would be better off without them. Most of the functionality > could be easily achieved using static class methods, and the rest may be > emulated with variable function names, etc. > > Comments? "Most of the functionality could be easily achieved using static class methods". As someone who uses both functions and classes with equal comfort, I have to say "GAH, NO NO NO!" to that statement. Classes as pseudo-namespaces are fundamentally wrong. Conceptually they're entirely different things. I have to shut people down every time they try to suggest that in Drupal. It's not just a conceptual issue, either. For a very practical example, consider that a namespaces can be split across any number of files. A class must be all in one file. That means if you want to group functions together, they MUST all be in one single monolithic file. That makes them, sorry, useless for anything even remotely interesting. 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). -- Larry Garfield larry@garfieldtech.com