Hi!

About namespaced functions and constants, the fact that they are not
autoloaded makes them useless for any code that wants some good
packaging. For example I looked at the Doctrine2 code, and (tell me if

This is not true. You can always load stuff manually - in fact, many languages don't have any autoloading at all and are just fine.

I also have a second strong grief against namespaced functions and
constants : due to their at runtime namespace resolution, static code
analysis is now very hard, even impossible in the general case! It is

In general case, it always was so. Think of $foo->$bar() - what is being called?

So, my first proposal for namespaced functions and constants is :
1. Remove namespaced functions and constants at all - promote
namespaced public static methods and class consts instead.

This won't happen, for obvious BC reasons. Please re-read the discussions on the list about namespaced functions to know what are reasons for their existence.

2. At runtime, when a namespaced identifier is used (lets say
\my\sub\ns\class_interface_constant_or_function), take the namespace
part of the identifier and if any, autoload it as if it were a class,
do not generate any error if the given class name is not found. (ie,
trigger something like class_exists('my\sub\ns', true);).

Autoloading for functions/constancs don't seem to have enough benefit to justify the complications. As for classes, you can always make you autoloader do anything you want with the name it receives.

--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

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

Reply via email to