Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98581 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75880 invoked from network); 18 Mar 2017 01:40:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Mar 2017 01:40:49 -0000 Authentication-Results: pb1.pair.com header.from=david.proweb@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=david.proweb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.66 as permitted sender) X-PHP-List-Original-Sender: david.proweb@gmail.com X-Host-Fingerprint: 209.85.213.66 mail-vk0-f66.google.com Received: from [209.85.213.66] ([209.85.213.66:35599] helo=mail-vk0-f66.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C4/7A-38004-F109CC85 for ; Fri, 17 Mar 2017 20:40:47 -0500 Received: by mail-vk0-f66.google.com with SMTP id k62so6399984vkb.2 for ; Fri, 17 Mar 2017 18:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=sFLfLhSHjr8IaCFbzYLgk63Mmwn7/s82QMX7U+R/+8o=; b=M4rE8go15mf7pQhq1gJHg/9d29ciMeLngE/FJemJtF5cvW0SBkJ7kiUCTF4gcw7Hce 3ag0jT1ir2ZnlJ3yHyRn03XzmtAItzumiu/I4Q3U6BmPm1+L4KkpnPzDhW9mmaQiQNeZ RAnAsJg/COEzyrr4AYH6zvyky3rXzps6qvlq9ZENghKdh26+gdygx/43pvgMr9xcoNtd l6YmPfqxGrPz8ONoJHHblihX//l/FIV+cKwuOYQha3YxB/LynE/k2rUdTLVj1mgYxgJC dXa0ZZSBXelj15DBZsQQzDqkwAphYL7Zm+JQ2RVdQYU4ORDCjJO/gDGFbZGBHdCygUkD CmPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=sFLfLhSHjr8IaCFbzYLgk63Mmwn7/s82QMX7U+R/+8o=; b=LDzLXBHl5v0s2V7kpFKVeRyiDyTBg4QIEDhbxrURlZXQsEyohLyWftGrgmaha2+FR5 42BldGvAvLOCYzZDJcy6atPpxq/cUsDnwgs6gr2zffw7CDRhml41XuUh0qxc7VwA5NCY FmfatpeU7N0nTakW5z8KA96ABCUpJatRKQcHTTGkn51igDl093f/H3Sm74lrLjtCqn3t Q7DcaaYW7qfKOr36cIk6yLRKoO6HYu4aMaLRY9+gM+107mRdNfy2h3qtmNNaUeC1As1h HnuYbS3cyF2mUobZnLlwPJN/VDyg8Gw2SZZDWOPG+wCUIB/PIT3gIefhw2VJFyJsQsVt aLZQ== X-Gm-Message-State: AFeK/H14zyf0Bq5qoTgcqB5+BSLYT9pGe8oXdqjaE2YbpUKoRzqf0cX1ZIQqHAGpoMl7zg2rYoQ2l9wkJx8XuA== X-Received: by 10.31.77.196 with SMTP id a187mr5733361vkb.99.1489801244910; Fri, 17 Mar 2017 18:40:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.132.204 with HTTP; Fri, 17 Mar 2017 18:40:24 -0700 (PDT) In-Reply-To: References: Date: Fri, 17 Mar 2017 22:40:24 -0300 Message-ID: To: Sara Golemon Cc: Niklas Keller , PHP Internals Content-Type: multipart/alternative; boundary=001a114dc58cfd2b70054af76117 Subject: Re: [PHP-DEV] Let range() return a generator? From: david.proweb@gmail.com (David Rodrigues) --001a114dc58cfd2b70054af76117 Content-Type: text/plain; charset=UTF-8 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 : > On Fri, Mar 17, 2017 at 10:46 AM, Sara Golemon wrote: > > On Fri, Mar 17, 2017 at 1:40 AM, Niklas Keller 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 --001a114dc58cfd2b70054af76117--