Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31768 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62000 invoked by uid 1010); 21 Aug 2007 05:57:25 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 61985 invoked from network); 21 Aug 2007 05:57:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Aug 2007 05:57:25 -0000 Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 63.205.162.114 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 63.205.162.114 unknown Windows 2000 SP4, XP SP1 Received: from [63.205.162.114] ([63.205.162.114:14530] helo=us-ex1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BB/03-36574-4CE7AC64 for ; Tue, 21 Aug 2007 01:57:25 -0400 Received: from [127.0.0.1] ([192.168.17.72]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 20 Aug 2007 22:57:22 -0700 Message-ID: <46CA7EBF.20909@zend.com> Date: Mon, 20 Aug 2007 22:57:19 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: internals@lists.php.net References: <46C9F217.8040804@chiaraquartet.net> <200708210039.26755.larry@garfieldtech.com> In-Reply-To: <200708210039.26755.larry@garfieldtech.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 21 Aug 2007 05:57:22.0567 (UTC) FILETIME=[244A1170:01C7E3B8] Subject: Re: [PHP-DEV] [PATCH] allowing multiple namespaces per file plus namespaces with brackets From: stas@zend.com (Stanislav Malyshev) > What happens if you mix them? > > namespace baz; > > namespace foo { > class Bar { > ... > } > } > ?> That's not the fun yet. This is: Now, is bar in namespace baz or not? I guess it is, otherwise it stops making any sense. So now when you see in the code it says "class bar" what do you do to know which namespace it is? Right, you go up to the code, counting closing and open brackets and hoping you didn't miss any and try to figure out if it's that main namespace or one of the other ones. Now next question - how ones in namespace foo are supposed to call class bar? They'd have to call it by full name, baz::bar, right? Welcome back, long names. But wait, we could use an import, right? So now we'd have block-local imports. And we'd have to track them per namespace-block. BTW, what about imports in baz - are they active in foo? What if baz wants to talk to class in foo - should it import it? And BTW - how the patch solves it - I didn't read all of it, but not sure it does it correctly. > Would the compiler have a heart attack if someone did: > > namespace foo { > namespace baz { > class Bar { ... } > } > } > ?> This syntax implies that baz has access to names in foo. The separate syntax doesn't. But that's only part of the story - remember the names/imports story above? Now take that and make it unlimited depth stack, since you'd have to track everything on *each* nesting level separately. I wouldn't want to open this can of worms. That'd produce messy engine and messy code. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com