Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62151 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33770 invoked from network); 14 Aug 2012 17:36:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Aug 2012 17:36:54 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.183 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.183 smtp183.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.183] ([67.192.241.183:38952] helo=smtp183.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CE/AF-00812-5BC8A205 for ; Tue, 14 Aug 2012 13:36:53 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp8.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 0CECC80FA; Tue, 14 Aug 2012 13:36:51 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp8.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id AFF548333; Tue, 14 Aug 2012 13:36:50 -0400 (EDT) Message-ID: <502A8CB2.7060708@sugarcrm.com> Date: Tue, 14 Aug 2012 10:36:50 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Aaron Holmes CC: "internals@lists.php.net" References: <50280D37.10109@moonspot.net> <502A7FFB.1090502@aaronholmes.net> In-Reply-To: <502A7FFB.1090502@aaronholmes.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Generators From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > That said, rewind() should behave consistently. I don't feel it makes > sense to have rewind() succeed at one point, and fail at another. It > would only cause confusion when not familiar with the behavior. Either > allow it, or don't. Not both. It does, since foreach uses rewind. So first rewind should succeed if you want iterators be usable in foreach. OTOH, on something like DB result set, next rewind does not make any sense, if you have non-seekable cursor, since the results consumed are gone and there's no way to get them back (you could rerun the query, but it might have side effects and nobody guarantees you'd get the same result anyway). So it makes sense for the generator to succeed on first rewind but fail on next ones. Note that generators by nature are stateful objects, so it is not unexpected that they would produce different result in different states. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227