On 2011-10-28, Nicolas Grekas <nicolas.grekas+...@gmail.com> wrote:
<snip>
> About PSR-0 and applying the same reasoning, I don't understand why
> the underscore in the namespace part is not replaced by a directory
> separator: because of it's class to path transformation, PSR-0 forbids
> having two different classes named A\B_C and A\B\C (they map to the
> same file). That is a good think, same reasoning for 1. above. But
> because of the "underscore in namespace exception", PSR-0 encourages a
> situation where class A_B\C can coexists with an other class A\B\C.
> Why forbid A\B_C and A\B\C, then allow A_B\C and A\B\C? That is
> inconsistent with argument 1. above, which we have used to justify
> PSR-0 equivalence for A\B_C and A\B\C... That is inconsistent to me.

There were several reasons for this.

First, to allow code following the current PEAR standards to work, we
obviously need to treat the "_" separator in class names as a directory
separator. Since the standard has its origins in the PEAR naming
conventions, this was a requirement.

Second, going back to the point made earlier in the thread about case
sensitivity, several projects indicated they planned to have lowercase
namespaces. As such, to allow for word separation, they wanted to use
the underscore character -- since namespaces must be in the character
set [a-zA-Z0-9_], this was the only available option. To allow
namespaces to use the underscore character, the standard then needed to
ignore underscores in substitutions on the namespace segment only.

So, to sum up:

 * Allows BC with existing standards
 * Allows greater naming flexibility in namespaces

Hope that answers your question.

-- 
Matthew Weier O'Phinney
Project Lead            | matt...@zend.com
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

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

Reply via email to