Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34624 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34838 invoked by uid 1010); 10 Jan 2008 00:09:29 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 34823 invoked from network); 10 Jan 2008 00:09:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jan 2008 00:09:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=tomi@cumulo.fi; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=tomi@cumulo.fi; sender-id=unknown Received-SPF: error (pb1.pair.com: domain cumulo.fi from 81.228.11.168 cause and error) X-PHP-List-Original-Sender: tomi@cumulo.fi X-Host-Fingerprint: 81.228.11.168 pne-smtpout4-sn1.fre.skanova.net Solaris 10 (beta) Received: from [81.228.11.168] ([81.228.11.168:49396] helo=pne-smtpout4-sn1.fre.skanova.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BC/D0-25966-63265874 for ; Wed, 09 Jan 2008 19:09:27 -0500 Received: from [192.168.1.3] (84.250.46.16) by pne-smtpout4-sn1.fre.skanova.net (7.3.129) (authenticated as kaisto-9) id 474FD021001DFF5B for internals@lists.php.net; Thu, 10 Jan 2008 01:09:03 +0100 Organization: Cumulo Studio To: internals@lists.php.net Date: Thu, 10 Jan 2008 02:05:50 +0200 User-Agent: KMail/1.9.7 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200801100205.51043.tomi@cumulo.fi> Subject: Set default namespace From: tomi@cumulo.fi (Tomi Kaistila) Sorry for the ambiguous subject line, but I could not find a better wording for it. Currently, when you use namespaces in PHP, whenever you want to call a function from inside a namespace you must either use the entire name of the namespace (potentially very long) or give it a shorter alias. Here is an example: namespace.inc namespace ProjectA; const WORD = 'foobar'; execute.php use ProjectA as A; print A::WORD; This works out fine. But when I change the two last lines in execute.php to: use ProjectA; print WORD; I get a warning saying "The use statement with non-compound name 'ProjectA' has no effect ..." and naturally also a notice about using a non-defined constant. So, the default namespace in use, is always global. What about if the default could be changed? It would put to rest the need to always specify the namespace from which to look for the function or class. This would mean that the last example of execute.php would be valid. You could also still access the global space with the following syntax: execute.php const BOOK = 'Two Towers'; use ProjectA; print ::BOOK; Any thoughts on this? Was this sort of approach considered when the namespaces were being implemented? Tomi Kaistila PHP Developer