Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31778 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14525 invoked by uid 1010); 21 Aug 2007 08:16:46 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 14509 invoked from network); 21 Aug 2007 08:16:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Aug 2007 08:16:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from [212.25.124.162] ([212.25.124.162:22060] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/F0-05201-A6F9AC64 for ; Tue, 21 Aug 2007 04:16:46 -0400 Received: (qmail 10824 invoked from network); 21 Aug 2007 08:16:40 -0000 Received: from internal.zend.office (HELO thinkpad) (10.1.1.1) by internal.zend.office with SMTP; 21 Aug 2007 08:16:40 -0000 To: "'Gregory Beaver'" , "'internals Mailing List'" , "'Stanislav Malyshev'" Date: Tue, 21 Aug 2007 12:16:39 +0400 Message-ID: <000001c7e3cb$9a80b160$6e02a8c0@thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 Importance: Normal In-Reply-To: <46C9F217.8040804@chiaraquartet.net> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 Subject: RE: [PHP-DEV] [PATCH] allowing multiple namespaces per file plus namespaces with brackets From: dmitry@zend.com ("Dmitry Stogov") References: <46C9F217.8040804@chiaraquartet.net> How about "import" statements? The had effect on current file. How they will behave with your patch? The import in one namespace will affect following namespaces... :) Also this change is inconsistent with renaming "namespace" to "package". Thanks. Dmitry. > -----Original Message----- > From: Gregory Beaver [mailto:greg@chiaraquartet.net] > Sent: Monday, August 20, 2007 11:57 PM > To: internals Mailing List; Dmitry Stogov; Stanislav Malyshev > Subject: [PHP-DEV] [PATCH] allowing multiple namespaces per > file plus namespaces with brackets > > > Hi all, > > This patch is also available at > http://pear.php.net/~greg/namespace.patch.txt > > The patch adds the syntax "namespace { *stuff }" and allows > multiple namespaces per file with no performance penalty or > added complexity as only 4 lines of code need to be changed, > and 9 lines of code added to implement this support! > > Basically, there is one use case of multiple namespaces per > file that the patch is designed to support, which is the > ability to cram many files into a single file. I have done > this for purposes of distributing things (prior to phar), it > is used by some with phing tasks for performance reasons, and > can have other uses as well. > > The patch provides the ability to do this, for example: > > namespace One { > require_once 'blah.php'; > class MyClass extends blah > { > function test() > { > echo "OK\n"; > } > } > function test() > { > echo "OK\n"; > } > } > > namespace Two { > class MyClass > { > function test() > { > echo "OK\n"; > } > } > function test() > { > echo "OK\n"; > } > } > ?> > > Note that the old format "namespace OneRingToRuleThemAll;" is > still fully supported, and should be the recommended format, > as build tools can easily take an entire file, change > namespace .*; into namespace .*{ and append to the > end of the file. > > The attached patch is against php6, but as you can see, a > blind monkey could port it to PHP_5_3 when the time comes. > All of the introduced changes are now tested, including the > error message for nested namespace declarations, and the > error message for multiple namespace declarations with ; > (which was previously untested by .phpt tests) > > Thanks, > Greg >