Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41767 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71637 invoked from network); 7 Nov 2008 21:36:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Nov 2008 21:36:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 69.16.228.148 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 69.16.228.148 unknown Linux 2.4/2.6 Received: from [69.16.228.148] ([69.16.228.148:55102] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 12/D0-02726-AE4B4194 for ; Fri, 07 Nov 2008 16:36:43 -0500 Received: from [83.228.56.37] (port=1265 helo=pc) by host.fmethod.com with esmtpa (Exim 4.69) (envelope-from ) id 1KyZ0R-0007Og-K4 for internals@lists.php.net; Fri, 07 Nov 2008 15:36:40 -0600 Message-ID: To: "internals Mailing List" References: <4914AFCA.40307@chiaraquartet.net> Date: Fri, 7 Nov 2008 23:36:31 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.fmethod.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fmethod.com Subject: Re: [PHP-DEV] [PATCH] bracketed namespace declarations From: sv_forums@fmethod.com ("Stan Vassilev | FM") > use blah\blah; > > $f = new blah; > > namespace one { > use foo\bar as blah; > $a = new blah; > } > > // what is this? > blah::hi(); > ?> > > Technically, you could argue that blah::hi() should resolve to > blah\blah::hi(), but it is very difficult to track and figure out what > "blah" means by eye. Thus, in the patch I implemented, if bracketed > namespace declarations exist, global use statements are not allowed, but > must exist within namespace ns {} brackets. > > This creates a problem - how do you combine namespaced and unnamespaced > code? To solve this, I introduced the oft-suggested "namespace {}" > ... Well, here's a cheesy mod of your example: I guess it's clear that code below or above a namespace is in the same global namespace, so "use blah\blah" will apply ot "blah::hi();". However, we do also need your suggestion: namespace [nothing] { ... } since one of the major design goals of the {} syntax variation was to allow people to merge multiple files for deployment. Something which several frameworks already do. When we merge two files with "use" clauses, we need a way to provide "blank namespace" scope so the "use" applies only to the relevant part of the code. We can't avoid your code example above either, since by default we don't require every piece of code to be in a namespace. If we allow {} scoping, it'll be awkward to suddenly require the remaining global code to be put in an explicit scope too, and people will be confused. Hence a solution that seems most natural to me, and covers all use cases is the following (where the scope # tells you where the "use" declarations apply):