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 <std_disclaimer.h>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to