Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60799 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49714 invoked from network); 12 Jun 2012 03:32:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jun 2012 03:32:38 -0000 Authentication-Results: pb1.pair.com header.from=soundasleep@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=soundasleep@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: soundasleep@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wg0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:38459] helo=mail-wg0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 77/C9-18025-458B6DF4 for ; Mon, 11 Jun 2012 23:32:37 -0400 Received: by wgbfg15 with SMTP id fg15so2983919wgb.11 for ; Mon, 11 Jun 2012 20:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=QL6aGj5LaIGSCV1n96KnYtrgQIe31Z2h8sH/JzAG7DQ=; b=VEuJXK3nXkS8amBK3I1DxXMUl3B24KjkzyXYC5MB2pV3cR0DHEa+N+oINFz/KlhFk0 spszT97z4s5C4BSrJBQJVhuo4zgfGQy2ovuL/s4fv3bfp0t99DyHxcQw03HYV2k8ZG9b hXcNImolnsVptdvAQdC2MJLF6AoYuyQWXBeMWH8EsuQwooNzIPi0rI19pm6/nK0yCsOf 8YmTDkbWq+/WPzSd0wwRL0hL2Nwg+MdiwNlHQsZq/McLn52n48I6xV27Ehyha+CNR9Z0 CwiOXJY4ZkHm1bjncWERAtrXNfIzCBUHB4RXs9iUC3ot3CEhygIa4ZZoORWhFF7yjq47 uvBQ== MIME-Version: 1.0 Received: by 10.180.101.170 with SMTP id fh10mr29117497wib.0.1339471953826; Mon, 11 Jun 2012 20:32:33 -0700 (PDT) Sender: soundasleep@gmail.com Received: by 10.180.100.38 with HTTP; Mon, 11 Jun 2012 20:32:33 -0700 (PDT) In-Reply-To: References: Date: Tue, 12 Jun 2012 15:32:33 +1200 X-Google-Sender-Auth: tc-UJHxAliUf8I8gCXx_B6NDgOo Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Generators in PHP From: jevon@jevon.org (Jevon Wright) I don't understand why you need to introduce two new keywords into the language - * and yield. Could you not solve it like follows? // Generator implements Iterable class AllEvenNumbers extends Generator { private $i; public __construct() { $this->i = 0; } function generate() { return ($this->i++) * 2; } } That way I think you can persist state (as part of the class instance) and implement rewind (per whichever way you do it - either caching the output, or serialising the class instance) without having to introduce yet more keywords. If this is instead a discussion to specifically implement yield, rather than simplifying the implementation of rewindable Iterators, it might be more useful to frame the discussion in that way. Jevon On Wed, Jun 6, 2012 at 5:35 AM, Nikita Popov wrote: > Hi internals! > > In the last few days I've created a proof of concept implementation > for generators in PHP. It's not yet complete, but the basic > functionality is there: > https://github.com/nikic/php-src/tree/addGeneratorsSupport > > The implementation is outlined in the RFC-stub here: > https://wiki.php.net/rfc/generators > > Before going any further I'd like to get some comments about what you > think of adding generator support to PHP. > > If you don't know what generators are you should have a look at the > "Introduction" section in the above RFC or in the Python documentation > at http://wiki.python.org/moin/Generators. > > Nikita > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >