Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33839 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53468 invoked by uid 1010); 7 Dec 2007 17:36:16 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 53452 invoked from network); 7 Dec 2007 17:36:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Dec 2007 17:36:16 -0000 Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 38.99.98.18 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 38.99.98.18 beast.bluga.net Linux 2.6 Received: from [38.99.98.18] ([38.99.98.18:41928] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1B/11-45053-E8489574 for ; Fri, 07 Dec 2007 12:36:16 -0500 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id E5263C0ECD8; Fri, 7 Dec 2007 10:36:11 -0700 (MST) Received: from [192.168.0.106] (CPE-76-84-15-179.neb.res.rr.com [76.84.15.179]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 5DDA4C0ECD7; Fri, 7 Dec 2007 10:36:11 -0700 (MST) Message-ID: <4759848D.5050007@chiaraquartet.net> Date: Fri, 07 Dec 2007 11:36:13 -0600 User-Agent: Thunderbird 2.0.0.6 (X11/20071022) MIME-Version: 1.0 To: Matthias Pigulla CC: Derick Rethans , PHP Developers Mailing List References: <4758A390.4040402@chiaraquartet.net> <00A2E2156BEE8446A81C8881AE117F199A06B9@companyweb> In-Reply-To: <00A2E2156BEE8446A81C8881AE117F199A06B9@companyweb> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: Re: AW: [PHP-DEV] A rebuttal to Re: RFC: Dropping Namespace From: greg@chiaraquartet.net (Gregory Beaver) Matthias Pigulla wrote: >> 1) recommend all global non-namespaced code that wishes to import >> namespaced code via "use Namespace::Classname" add a "namespace >> __php__;" at the top of the file, and that the __php__ namespace be >> reserved for use by end-user applications. > > >> 5) namespaces provide these benefits that are not available in PHP: >> a) short, unqualified descriptive class names can be used without >> fear of conflicting with an internal class > > Interesting as I was not aware before that when a namespace is active > the import goes into that namespace and not into global scope > (clashing with core classes there). > > But please consider: > > -- Date.php -- > > -- test.php -- // assume it would require Date.php when asked to do so print > get_class(new Date()); ?> > > Although this code has been future-proofed by adding the "namespace > __php__", it will break if the core introduces a class named Date > (will use the wrong class!). It also breaks without the namespace, > and maybe it is a mistake to rely on autload here. But this is a case > where using namespaces does not protect you from surprises unless you > explicitly import ("use") all the classes you need. But that is not > as simple as putting a namespace statement on top of all your files > to be save. > > If new, future core extensions showed up in a reserved PHP:: > namespace, you would be >:-). Exactly - which is why you should never put classes, functions or constants in the __php__ namespace. The convention I am proposing is to only use __php__ for code that *uses* re-usable components, not *declares* them. In this case, your example would be revised as: This convention serves two purposes 1) library code is always explicitly "use"d 2) name conflicts are impossible The suggestion to make "namespace __php__;" implicit is very interesting, but would defeat its purpose, which is to separate declarations from use. Another off-list suggestion was to make "use" outside of a namespace declaration an error, as this is generally a bad idea that can lead to many "gotchas". Greg