Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41920 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57707 invoked from network); 15 Nov 2008 09:47:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Nov 2008 09:47:01 -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:55217] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/C7-07308-49A9E194 for ; Sat, 15 Nov 2008 04:47:00 -0500 Received: from [83.228.56.37] (port=1438 helo=pc) by host.fmethod.com with esmtpa (Exim 4.69) (envelope-from ) id 1L1Hk0-0007BW-Sn for internals@lists.php.net; Sat, 15 Nov 2008 03:46:57 -0600 Message-ID: <3C719ED4B1154E88ADA3A76835B98809@pc> To: References: <49188698.1050505@grudl.com> <49188BD0.9090100@kukulich.net> <4918A3F8.4070809@chiaraquartet.net> <4919A9BD.2020703@grudl.com> <491DE402.4000600@chiaraquartet.net> <72.BB.07308.119ED194@pb1.pair.com> <491E0297.20108@chiaraquartet.net> Date: Sat, 15 Nov 2008 11:45:27 +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] Re: Namespace resolution rules has been changed? From: sv_forums@fmethod.com ("Stan Vassilev | FM") > Hi Marcin, > > Stan also requested this, so it should be considered as a possibility. > > Personally, I would rather not introduce this land mine. It requires > the user to do an implicit prepending of namespace name ("foo") to "bar" > in the use statement as well as a translation of "A", which could fast > lead to unreadable code. > > It is probably best to simply require a fully qualified name where it is > intended. Thus > > 1) require leading "\" in use statements > 2) allow "namespace\blah" in use statements, as this is a valid fully > qualified name. > > namespace my\ns; > > // this is a better way to do the suggested "use bar as A;" > use namespace\bar as A; > use \bar as B; > > class mine extends \my\parentclass {} > ?> Greg, I can't spot where does your example differ from what I and Marcin suggested? Please explain. As for the leading \ for fully qualified identifiers, well it's a necessary evil. As you said yourself PHP is PHP, and we have unique constraints to meet, we have no scopes, we have no compile time packaging of the resources, and since we don't have meta files describing the namespace resources (wink wink...), we should stick to a single-rule no-ambiguity system. For me the only way to make it clear to both humans and parsers alike is the filepath semantics, in all places, including use. It's not perfect, there's no completely problem-free solution, but "prepend \ for absolute path" is able to become muscle memory, while other mixed solutions I've seen are more confusing and require more thinking: "wait in this context what was what?". And there's one more pain point which I posted earlier on the list about, but now as I prepare my framework for 5.3 namespaces, I *really* feel the pain in practice: the inability to pass a class/function name without specifying it fully as a string. My suggestion was: use foo\bar\baz as alias; $name = nameof alias; // $name == 'foo\bar\baz' But this introduces a new keyword: nameof, which could clash with function/class/constant "nameof" in existing source code. I could suggest simply not having "nameof" and having direct assignment assign the class name, but then we clash with constants which have the same name as the class. So that's not doable either. But it's definitely in-your-face issue while using namespaced code. Regards, Stan Vassilev