Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41279 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45295 invoked from network); 19 Oct 2008 18:10:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Oct 2008 18:10:42 -0000 X-Host-Fingerprint: 74.225.1.89 adsl-225-1-89.mia.bellsouth.net Received: from [74.225.1.89] ([74.225.1.89:23528] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EC/AE-29559-1287BF84 for ; Sun, 19 Oct 2008 14:10:41 -0400 To: internals@lists.php.net Message-ID: <48FB781E.4010507@gmail.com> Date: Sun, 19 Oct 2008 14:10:38 -0400 User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 CC: Greg Beaver References: <48F653FF.5010106@chiaraquartet.net> <48FB74E7.6050007@gmail.com> In-Reply-To: <48FB74E7.6050007@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 74.225.1.89 Subject: Re: my last attempt at sanity with namespaces From: jrhernandez05@gmail.com (Jessie Hernandez) Jessie Hernandez wrote: > > Hi Greg, > > I've read through the posts and the RFC and am not sure if this was > discussed before, but there is one other proposal I'd like to throw out > there: why not require all classes that are inside namespaces to be > explicitly imported? This would follow the AS3 approach > (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/statements.html#import). > > > I believe this would solve the issue with the namespace separator at > compile-time. The namespace separator can be left as :: and would only > be used in certain cases, such as when creating objects dynamically > (i.e. $c = 'MyNs::MyClass'; $o = new $c;). The double-colon > would work dynamically, since at runtime you can tell what's a namespace > and what's a class. > > So the class resolution rules would change to the following: > > 1) If the class was explicitly use'd, then use that class. > 2) If not, look for the class in the global namespace (this would > include internal classes). > > If one wanted to have a custom Exception class inside a namespace, one > would first alias the core Exception class and then extend from that: > > use Exception as PhpException; > > class Exception extends PhpException {} > ?> > > > Thoughts, comments? > Adding to this, I would require all _elements_, not just classes, to be use'd (this is also in line with AS3). This would allow functions and constants to also be namespaced. Any use of :: at compile-time would be used to separate a class from a member. For example, you could never use MyNs::MyClass::myMethod, but since a "use" statement is required, you would use MyClass::myMethod directly. -- Jessie Hernandez Zend Certified Engineer (http://zend.com/zce.php?c=ZEND006359&r=222727282)