Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34629 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26191 invoked by uid 1010); 10 Jan 2008 09:42:33 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 26175 invoked from network); 10 Jan 2008 09:42:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jan 2008 09:42:32 -0000 Authentication-Results: pb1.pair.com header.from=indeyets@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=indeyets@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.178.243 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: indeyets@gmail.com X-Host-Fingerprint: 64.233.178.243 hs-out-0708.google.com Linux 2.4/2.6 Received: from [64.233.178.243] ([64.233.178.243:29193] helo=hs-out-2122.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/B2-03358-788E5874 for ; Thu, 10 Jan 2008 04:42:32 -0500 Received: by hs-out-2122.google.com with SMTP id l65so609518hsc.7 for ; Thu, 10 Jan 2008 01:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=dvCx/qPC+JLCjJflQjzYkvcYQw2KLdpcT+zsR0oj9UA=; b=KYYsk1XoAStDiClNhzUHBcy7hVi6PawSeaswWvHjBBa8rFfAGOaHuay91Yoov6xC+B8kqrseMUvMk09xg0Ec4Rh1Jue3tPuaX+TNWG7U4FG0gtbNw7q58d2jR6WsLf03G0+7wkfahZODBepmiq+mMOUn9v5ZSf/+la/60pDuNu4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=rFUa3wKboL+mBd4RHPitXRGvdsH4zDUhLPXEwm7UWuj4vd+V87DHEkjl/6u5zoPj7NCVfpCcv/79nC/CqP2/bTarUHagVRDWdkdADykuGLi3YZL0XR4YYnRQzkQaQjKOte3YM3CuV/7G5dFLYY/TnQjM9Gaj27ao/PvtdBTSnNU= Received: by 10.151.82.3 with SMTP id j3mr692407ybl.78.1199958149474; Thu, 10 Jan 2008 01:42:29 -0800 (PST) Received: by 10.150.57.12 with HTTP; Thu, 10 Jan 2008 01:42:29 -0800 (PST) Message-ID: Date: Thu, 10 Jan 2008 12:42:29 +0300 To: "Tomi Kaistila" Cc: internals@lists.php.net In-Reply-To: <200801100205.51043.tomi@cumulo.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200801100205.51043.tomi@cumulo.fi> Subject: Re: [PHP-DEV] Set default namespace From: indeyets@gmail.com ("Alexey Zakhlestin") "use ProjectA;" is equivalent of "use ProjectA as ProjectA;" if you want to use something from namespace you should "use" that something. for example: "use ProjectA::BOOK;" On 1/10/08, Tomi Kaistila wrote: > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Alexey Zakhlestin http://blog.milkfarmsoft.com/