Bart de Boer schrieb:
> So, if namespace JessieStuff contains multiple classes. They would all 
> become JessieStuff_ClassName.
> 
> Assuming the package relies on its own classes, it wouldn't be able to 
> call them anymore because all their names have changed.

First of all, everything INSIDE a namespace is supposed to be able to
use its siblings without any namespace operators or prefixes. This is
out of scope here. The "import with as" is supposed to be aliasing, not
replacing.

And for the auto-prefixing, I think of it as an aggressive use of the
"as" option of the import statement. An import makes everything that is
inside a namespace available in the global namespace. Normally, the
names from inside the namespace are kept, so one could use SimpleClass
instead of JessieStuff:::SimpleClass. To avoid collisions with
OllStuff::SimpleClass, there is the "as" option. And my suggestion is to
give Mike an automatism for import with "as" that emulates the current
recommendation of prefixing everything:

  /*
   * this encounters a namespace. The auto-prefix-import option
   * is active so EVERYTHING is inside the namespace is imported
   * with a prefix of "JessieStuff_".
   */
  require 'JessiePackage.php';
  $x=new JessieStuff_SimpleClass();

This implements a one-way-availability for packages using namespaces to
users hating them. Of course, Mike shouldn't count on successfully
sharing his code using Jessie's stuff with others that prefer to use the
namespaces.

OLLi

References: http://en.wikipedia.org/wiki/XML_namespace

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

Reply via email to