Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62129 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19258 invoked from network); 13 Aug 2012 16:09:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Aug 2012 16:09:36 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:47124] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D8/AA-00812-FB629205 for ; Mon, 13 Aug 2012 12:09:36 -0400 Received: by lahl5 with SMTP id l5so2136068lah.29 for ; Mon, 13 Aug 2012 09:09:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=1b8WDr94jWgNivT56Ysh5bywR/bLVs25Efsdnakj1Sk=; b=H6xbsfIodncPwOweMIkJ9S+mR5s9GKjYpDECttA2q6tE3qWAoPMYSqjyF82YFiZ8Xb wumsUTpLn5mBq2djg6TY6GEhVmCMGkSiQlOvMLVdtYOKDoQswJpvQGtF10ILxOEMtG2W FJ8fchlEehYFeW41Gb5soEw4v7txA+tVp+9w/+DF4Iro5VFp6QKIg6aLuFQLjWAYOJ+Q f6KL/FR9vKsh3gmJTjkD0H15y0qQfnbTBwUKuWJSU6DeYcBL2/jwO3Jg9WZGG7oQZwbd h7GH0IyEzWbOr1mTJQN6zSkW1VJwhHjIiFzEILJigA3SOF0bZy/Zih/AkK7P76zetRga IkPA== MIME-Version: 1.0 Received: by 10.152.113.68 with SMTP id iw4mr12364994lab.50.1344874173126; Mon, 13 Aug 2012 09:09:33 -0700 (PDT) Received: by 10.152.122.51 with HTTP; Mon, 13 Aug 2012 09:09:32 -0700 (PDT) In-Reply-To: <50280D37.10109@moonspot.net> References: <50280D37.10109@moonspot.net> Date: Mon, 13 Aug 2012 18:09:32 +0200 Message-ID: To: Brian Moon Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [RFC] Generators From: nikita.ppv@gmail.com (Nikita Popov) On Sun, Aug 12, 2012 at 10:08 PM, Brian Moon wrote: > Also, not allowing rewinding is unintuitive for something that is an > iterator in PHP. If I can foreach() it and I can call next() on it, I expect > to be able to reset() it as well. IMO, you would need to issue a FATAL PHP > error if that simply is not allowed. Or you have to have a second syntax for > what to do in that case. At that point, you are implementing Iterator. Currently I'm planning to implement the following behavior for rewind(): * If before first yield: Resume to first yield (this priming behavior is common to all the Iterator methods) * At first yield: No-op * After first yield: Recoverable fatal error So this would allow you to call ->rewind() after creating the generator, but will throw an error if you try to do so later. Another thing that I'd like to do is drop the ->close() method. It doesn't really make sense to explicitly close generators. Any objects to those two things? Nikita