> On 19 Jun 2016, at 7:57 PM, Rasmus Schultz <ras...@mindplay.dk> wrote:
> 
> I am well familiar with this approach, and it does not scale - not
> only would you be aggressively loading every installed view-helper
> anytime you render a view, you would even be loading them when you're
> *not* rendering a view.
> 
> I'm afraid the best we could do at this point, without changing the
> language, is a establish a convention for autoloading functions
> (and/or namespaces of functions) from files, based on static analysis
> of template files.
> 
> But that is pretty complex - on the organizational side, it requires
> developers to agree on and adopt a convention, and on the technical
> side, you need static analysis and thereby most likely a cache layer
> as well.
> 
> It's all possible, but most people aren't going to put up with this
> much complexity for something this simple.
> 
> Hmm. What if we could import static methods into file scope and use
> them as functions?
> 
> use My\Namespace::my_function;
> 
> my_function(); // <-- effectively My\Namespace::my_function()
> 
> This would leverage auto-loading at least... I mean, it's still
> effectively just abusing classes as pseudo-namespaces, so there is
> that - but it would work with e.g. Composer right away, and probably
> with many existing static classes?
> 
> Yeah, it's still ugly...
> 
> 

Ugly, but brilliant! +1

David

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

Reply via email to