Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31765 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56308 invoked by uid 1010); 21 Aug 2007 05:39:44 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 56292 invoked from network); 21 Aug 2007 05:39:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Aug 2007 05:39:44 -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 204.127.192.85 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 204.127.192.85 rwcrmhc15.comcast.net NetCache Data OnTap 5.x Received: from [204.127.192.85] ([204.127.192.85:38422] helo=rwcrmhc15.comcast.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 87/22-36574-D9A7AC64 for ; Tue, 21 Aug 2007 01:39:43 -0400 Received: from earth.ufp (c-71-228-13-89.hsd1.il.comcast.net[71.228.13.89]) by comcast.net (rwcrmhc15) with ESMTP id <20070821053938m1500t5atle>; Tue, 21 Aug 2007 05:39:38 +0000 Received: from localhost (localhost [127.0.0.1]) by earth.ufp (Postfix) with ESMTP id 50F3FD7C1E for ; Tue, 21 Aug 2007 00:39:38 -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 BPBN5soA4TWk for ; Tue, 21 Aug 2007 00:39:38 -0500 (CDT) Received: from vulcan.ufp (vulcan.ufp [192.168.42.4]) by earth.ufp (Postfix) with ESMTP id 33857D7AA8 for ; Tue, 21 Aug 2007 00:39:27 -0500 (CDT) To: internals@lists.php.net Date: Tue, 21 Aug 2007 00:39:26 -0500 User-Agent: KMail/1.9.6 References: <46C9F217.8040804@chiaraquartet.net> In-Reply-To: <46C9F217.8040804@chiaraquartet.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200708210039.26755.larry@garfieldtech.com> Subject: Re: [PHP-DEV] [PATCH] allowing multiple namespaces per file plus namespaces with brackets From: larry@garfieldtech.com (Larry Garfield) Greg: You say that the old java-package-style definition still works, in addition to braces. I presume then that the following are equivalent: What happens if you mix them? Is the full name of the class then foo::Bar, baz::Bar, or foo::baz::Bar? Would the compiler have a heart attack if someone did: instead of: or: namepsace foo::baz { class Bar { ... } } I don't know anywhere near enough about the engine code to be able to read your patch below, so I'm just trying to understand all the various implications of this syntax. On Monday 20 August 2007, Gregory Beaver wrote: > 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 -- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson