namespace/package feature in PHP 5?

From: Date: Thu, 19 Jul 2001 13:28:47 +0000
Subject: namespace/package feature in PHP 5?
Groups: php.dev 
Request: Send a blank email to php-dev+get-60293@lists.php.net to get a copy of this message
Greetings. First of all, if anyone can direct me to a centralized place that will tell me what features the developers are considering for PHP 5, I'd appreciate it. Secondly, I'd like to make a request for real namespace support (a la Perl or even Java) in PHP 5. I think this is one of the most important new features to add. PEAR has attempted to overcome the restrictions of a language without namespaces, and a lot of wonderful code has been written in PEAR; but a lot of artificial requirements are enforced in the PEAR standards that would not be necessary with namespace support. It would be great if you binary extensions and PHP code itself, both, could declare themselves as part of a particular namespace. In the tradition of Perl, as PHP often follows, scope-resolution operator (::) would be great tokens in a namespace. I know this operator is also used to call class (i.e., static) methods, but the meaning could remain consistent if a class name is considered a possible final resolution of a namespace. In the tradition of Java, multiple scopes could be specified to avoid namespace collisions. 'net::php::pear' could be a valid namespace, 'net::php::pear::DB' could specify the DB class, and 'net::php::pear::DB::connect' could indicate that the connect class method should be called. DNS-based namespaces is just an idea; nothing like this would be enforced, of course, just encouraged to avoid collisions. With multiple scopes in a namespace, and just a single directory in the include_path, including files could be greatly simplified. There could be an INI directive to specify allowable extensions for PHP module files, and the statement 'use php::pear::DB;' would include the relative path (for example) "php/pear/DB.phpm". Also 'include' and 'require' could be used for backward compatibility. Any module that is 'use'd could have an inherent 'include_once' or 'require_once' quality. Including files directly could also be allowed for backward compatibility. For a module to declare itself as part of a particular namespace, it could say: 'namespace php::pear::DB;'. Also, any script could temporarily change its namespace by the same method. I admit that I do not help develop any part of the PHP distribution, but I would be glad to engage anyone in discussion about this feature; and I would be glad to help with the design of such a feature. Thanks for your time. Dean Hall.

« previous php.dev (#60293) next »