Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47040 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84684 invoked from network); 23 Feb 2010 23:23:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Feb 2010 23:23:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 78.32.209.33 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 78.32.209.33 freshmint.phcomp.co.uk Linux 2.6 Received: from [78.32.209.33] ([78.32.209.33:63679] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/03-03187-473648B4 for ; Tue, 23 Feb 2010 18:23:33 -0500 Received: from addw by mint.phcomp.co.uk with local (Exim 4.63) (envelope-from ) id 1Nk46C-0008Ex-Fp; Tue, 23 Feb 2010 23:23:28 +0000 Date: Tue, 23 Feb 2010 23:23:28 +0000 To: "Ionut G. Stan" Cc: internals@lists.php.net Message-ID: <20100223232328.GE16412@phcomp.co.uk> Mail-Followup-To: "Ionut G. Stan" , internals@lists.php.net References: <4B54FC87.8070106@zend.com> <4F.56.22457.408955B4@pb1.pair.com> <4B55D850.8000604@zend.com> <4B808294.1070801@keryx.se> <4B844DBA.4050804@zend.com> <4B845E0C.7040005@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4B845E0C.7040005@gmail.com> User-Agent: Mutt/1.4.2.2i Organization: Parliament Hill Computers Ltd Subject: Re: [PHP-DEV] variables in namespaces, was: On closures and lamdba From: addw@phcomp.co.uk (Alain Williams) On Wed, Feb 24, 2010 at 01:00:28AM +0200, Ionut G. Stan wrote: > ** namespaced functions don't make any difference, as variables aren't > namespaced. I never did understand *why* variables were not namespaced. However, since 5.3 has been out for a while it might make things difficult to make them - would break BC, unless the following was adopted -- something that would really make me happy: namespace foo; var $bar; // Creates the variable $\foo\bar; I *still* really want to have something like perl's ''use strict''. If 'var' is used outside of a function then ''use strict'' becomes switched on, the way to access a global variable would be to use the namespace \ - first declare it: var $\globalName; Note that the 'global' keyword would still be used in functions: function blob() { global $\globalName; // Import from $GLOBALS global $bar; // Import from current namespace } The above might even be extended: namespace foo; public $bar; // Creates a variable $\foo\bar this is available to code outside the namespace private $fred; // Creates $\foo\fred that cannot be accessed by code outside the namespace Variables in a namespace would not appear in $GLOBALS. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php Past chairman of UKUUG: http://www.ukuug.org/ #include