Re: New escaped output operator
| From: | David Muir | Date: | Sun, 19 Jun 2016 12:59:58 +0000 |
| Subject: | Re: New escaped output operator | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-94119@lists.php.net to get a copy of this message | ||
> On 19 Jun 2016, at 7:57 PM, Rasmus Schultz <rasmus@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