There are some way to PHP be flagged before run some function, and
understand that you wants to return a Generator instead of array?
For instance: new Generator(range(1, 1000)) makes range() work like a
generator instead of return an array - it's an alternative to avoid new
keywords.
Or, maybe, some side implementation like Generator::range(1, 1000),
Generator::array_values($array), etc. (Currently, for instance, we can
simulate the range() Generator, but not array_values())

2017-03-17 22:14 GMT-03:00 Sara Golemon <poll...@php.net>:

> On Fri, Mar 17, 2017 at 10:46 AM, Sara Golemon <poll...@php.net> wrote:
> > On Fri, Mar 17, 2017 at 1:40 AM, Niklas Keller <m...@kelunik.com> wrote:
> >> Yes, that's a BC break. Instead of changing it, there could be a new
> >> function. But as it can be simply built in userland, I don't see much
> >> reason to have it in core.
> >>
> > 100% agreed.  This is a 3 line function and doing it in userland means
> > you can use it in 5.5 or later.
> >
> > function range($low, $high) {
> >   for ($i = $low; $i <= $high; ++$i) { yield $i; }
> > }
> >
> In fact, here: This is how easy that is.
>
> https://packagist.org/packages/phplang/generator
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
David Rodrigues

Reply via email to