On Fri, Nov 7, 2008 at 7:24 PM, Stan Vassilev | FM
<[EMAIL PROTECTED]> wrote:
>> What about adding a function that behaves like __autoload, but with
>> respect to namespace wildcards?  Something like:
>
> Hi,
>
> Ok so first:
>
> 1) We can't implement wildcards since a wildcard needs to be expanded to a
> set of concrete classes at runtime for it to make sense, and we don't know
> what those classes are (due to autoloads and "conditional" require/include
> constructs).
>
> 2) There can't be a method to resolve wildcards, since namespaces currently
> work 90% at the parse level, before any PHP code has executed. This is
> required for good performance and simplicity.
>
> 3) I have emailed Greg a simple idea for solving this with a INI-like "meta"
> namespace file, a simple file we can put in our include path, which
> describes the resources of a namespace and optionally their location.
>
> For example let's say you have namespace My\Name\Space, and inside you have
> classes "Foo", "Bar", functions "baz" and constants ONE, TWO. In one of your
> include paths, you'll create a file called "My.Name.Space.nsmeta" and put
> the following inside:
>
> class Foo = "path\to\Foo.class.php"
> class Bar = "path\to\Bar.class.php"
> function baz = "path\to\baz.func.php"
> const ONE = "\path\to\constants.php"
> const TWO = "\path\to\constants.php"
>
> This file you can generate from your framework, or even write by hand, as
> you see it's very simple to write/read, and tokenizes with the existing PHP
> tokenizer.

Sounds like an idea for custom extension, but I doubt this would work
as a general approach.
It limits dynamic nature of php, so won't be suitable for all cases

Did you see this extension?
http://pecl.php.net/package/automap

> Since this file will be read at parse time, it has the ability to solve the
> following problems:
>
> 1) zero-performance-impact namespace wildcards (especially with an opcode
> cache like APC, XCache etc.)
> 2) faster resource loading (PHP can autoload resources from the location map
> above without you writing a slow __autoload runtime procedure)
> 3) you can load on demand now any namespace resources: class, functions,
> constant, not just classes.
>
> Naturally this is not for 5.3 as we all want 5.3 stable and out as soon as
> possible. But it has the potential to simplify drastically some workflows,
> especially in large complex frameworks, so if it picks up, maybe 5.4, or 6
> or who knows.
>
> Regards,
> Stan Vassilev
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Alexey Zakhlestin
http://blog.milkfarmsoft.com/

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

Reply via email to