Re: namespace separator and whining
| From: | Greg Beaver | Date: | Tue, 28 Oct 2008 00:21:32 +0000 |
| Subject: | Re: namespace separator and whining | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-41493@lists.php.net to get a copy of this message | ||
Josh Davis wrote:
> 2008/10/27 Stanislav Malyshev <stas@zend.com>:
>
>> 1) check for namespaced\classname
>> 2) try to autoload namespaced\classname
>> 3) fail
>
> Ok, that makes some sense wrt your position, which I originally
> interpreted as namespace/internal/autoload.
>
> You want to force users to use the full name at all times. IOW, you
> want to sacrifice convenience for performance. On the upside, no
> ambiguity whatsoever. "new Foo" is always a namespaced class. The
> downside is that it makes it harder for users to copy/paste code from
> current tutorials and examples, they will have to fix the class names.
> Also, a few people will probably regret not being able to
> auto-magically override some internal classes (e.g. override PDO to
> log queries and what not) and it will probably increase the amount of
> complaints about peppering one's code with backslashes.
<?php
namespace Foo;
use \PDO;
$a = new PDO; // $a is an object of class PDO
?>
<?php
namespace Foo;
use Clever\newversion\of\PDO;
$a = new PDO; // $a is now an object of class Clever\newversion\of\PDO
?>
Greg