Re: RE : Namespaces and __autoload()
| From: | Stut | Date: | Wed, 12 Sep 2007 13:00:06 +0000 |
| Subject: | Re: RE : Namespaces and __autoload() | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-32287@lists.php.net to get a copy of this message | ||
Paweł Stradomski wrote:
W liście LAUPRETRE François z dnia środa, 12 września 2007 12:38:This would need to come from the user implementation of __autoload through naming conventions or a lookup table. PHP does not get involved with resolving a type to a filename, and rightly so. -Stut -- http://stut.net/But how can interpreter know if it's looking for class or interface? There are obvious cases (class X implements Y, class A extends B, interface A extends B), but what with following language construct: function doSomething (Service s) {...} PHP tries to autoload type Service, but it can't know if it's looking for interface or class. Both are possible.What do you mean by "try both"? Could you explain a bit more on that?Yes. PHK's autoload handler is not filename-based. It works as a (poor man's :) runtime linker, with a symbol map. In this map, interfaces and classes have different symbol types. Today, when this handler receives a request, it cannot know if it should look for an interface or a class. So, it has to search both in turn. Please consider that filename-based autoload handlers are just a primitive implementation. If you consider only this family of handlers, that's right: getting the symbol type is not very important. But, with smarter map-based autoload handlers, it becomes very interesting to extend the feature to functions and, there, providing the symbol type along with the requested value becomes mandatory.