Re: Call it: allow reserved words in a class or not?
| From: | Matthew Schiros | Date: | Fri, 07 Nov 2008 08:03:14 +0000 |
| Subject: | Re: Call it: allow reserved words in a class or not? | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-41751@lists.php.net to get a copy of this message | ||
What about adding a function that behaves like __autoload, but with
respect to namespace wildcards? Something like:
<?php
function __namespace_autoload($namespaceName) {
$dirHandle = opendir("/path/to/app/" . $namespaceName);
while(false !== ($file = readdir($dirHandle))) {
if(substr($file,-3) == "php") {
require_once("/path/to/app/" . $namespaceName . "/" . $file);
}
}
}
?>
That would allow for Stan's "use foo\bar\*" without impacting the
performance of normal __autoload() calls.
Johannes Schlüter wrote:
> On Thu, 2008-11-06 at 22:19 -0600, Josh Thompson wrote:
>> I don't understand why in the namespaced example no one seems to have a
>> problem with new A() meaning new \foo\bar\A(), but we can't use the *
>> wildcard to do the same thing?
>
> Since we don't reliable know all possible classes, think about
> _-autoloading classes, which means we'd have to do more work during
> execution, which can be a slowdown.
>
> johannes
>
>
--
--------------------------------------------------------------------
Matthew Schiros
President, InvisiHosting.com
Web Development & Anonymous Web Host
Security Through Anonymity!
e: schiros@invisihosting.com
c: 512-466-4146
f: 888-521-4772
aim: invisirevolution
--------------------------------------------------------------------