Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41924 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96145 invoked from network); 15 Nov 2008 16:25:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Nov 2008 16:25:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 74.125.44.30 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 74.125.44.30 yx-out-2324.google.com Received: from [74.125.44.30] ([74.125.44.30:39497] helo=yx-out-2324.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2F/94-61433-FF7FE194 for ; Sat, 15 Nov 2008 11:25:36 -0500 Received: by yx-out-2324.google.com with SMTP id 3so772298yxj.83 for ; Sat, 15 Nov 2008 08:25:33 -0800 (PST) Received: by 10.65.73.16 with SMTP id a16mr2104941qbl.89.1226766332540; Sat, 15 Nov 2008 08:25:32 -0800 (PST) Received: from ?192.168.0.106? ([76.84.4.101]) by mx.google.com with ESMTPS id s27sm3326456qbs.12.2008.11.15.08.25.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 15 Nov 2008 08:25:31 -0800 (PST) Message-ID: <491EF84E.5040501@chiaraquartet.net> Date: Sat, 15 Nov 2008 10:26:54 -0600 User-Agent: Thunderbird 2.0.0.17 (X11/20080925) MIME-Version: 1.0 To: Stan Vassilev | FM CC: internals@lists.php.net 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> <3C719ED4B1154E88ADA3A76835B98809@pc> In-Reply-To: <3C719ED4B1154E88ADA3A76835B98809@pc> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Namespace resolution rules has been changed? From: greg@chiaraquartet.net (Gregory Beaver) Stan Vassilev | FM wrote: >> 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. I would not allow "use blah\blah as bar;" > 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' Are you aware of __NAMESPACE__? Also, if you are using a lot of external namespace names, you might consider simply defining constants: namespace foo\bar\baz; const ns = __NAMESPACE__; then you can simply do use foo\bar\baz; $name = baz\ns; I don't see a huge pressing need for nameof since the above is 3 extra lines of code - total - per NS. If this sounds good, I will add an example to the new docs yet-to-be-committed. Greg