Re: Idea: ifdef-like feature to ease userland BC
| From: | Marco Schuster | Date: | Sat, 08 Mar 2014 23:33:39 +0000 |
| Subject: | Re: Idea: ifdef-like feature to ease userland BC | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-73016@lists.php.net to get a copy of this message | ||
Hi Chris,
On Sun, Mar 9, 2014 at 12:01 AM, Chris Wright <daverandom@php.net> wrote:
> I'm not necessarily in favour of this idea as a core feature but to
> give a more practical example of how this could be useful: generators
> can give considerable efficiency gains where previously more resources
> would have been consumed by a process yielding values over time.
> Before 5.5, generator code would cause a parse error.
> [...]
> Another advantage for performance-minded people is that a
> pre-processor is a one-shot deal, whereas runtime checks are
> potentially performed a few hundred times a second with the exact same
> result every time for ever more.
>
> **However** the thought occurs that, while potentially useful, a
> pre-processor of this nature could easily be done with a userland
> implementation, a composer dependency and a composer
> after-install/after-update script...
Yep, I had code like yours in mind when asking.
One problem of doing it with Composer, for example, is that it is not
compatible with stuff like WordPress plugins - I personally would
really like to be able to use "modern" features while still allowing
for all those myriads of version combinations provided by web hosts.
One idea to do this with a "polyfill" could be (expensive)
preprocessing with file_get_contents() and eval(), but I think that
step would offset any performance gains by using goto, generators etc.
Marco
--
Marco Schuster
IT-Beratung, Web Development
Blütenstr. 23
80799 München