Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62142 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92627 invoked from network); 14 Aug 2012 12:37:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Aug 2012 12:37:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=alex.aulbach@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=alex.aulbach@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: alex.aulbach@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gh0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:55094] helo=mail-gh0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 39/A7-00812-F964A205 for ; Tue, 14 Aug 2012 08:37:51 -0400 Received: by ghbg24 with SMTP id g24so395023ghb.29 for ; Tue, 14 Aug 2012 05:37:48 -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=v9Iwhp07OosK/KRRGz553W0gkzeeSkm757sOri1opOU=; b=0NLkSkJG4mHWZkNzfocyTLq2ZRurNYFEFvqK4IF1K6LNscBhdAtVvgEe5b9wYSMCpM lagjttvaPm4DdF3VcOJG6TzMnNAN5Z5bEZQ7veCnMet3U6XuJt6SefZhwjkBGkNIRybv xGmXF5YytTYpZyEhtkvrldLp4Tys0MpP8FvDukQCOyvdfFlN+8jF5YHZAcJmS+yEUHEz tCo4qfp4ojU3YZz9DlqEZ5rc2hZWjsnsnr1dK/8bPShnxpOafH5x+wkBpoZ/5bJHou4a 4LoL/Nv37Ut24UMtmX+mH/4pCN4ZQzFOSmN3sPZL/l7xjYZIOV8ctLIm9v3Q0cQqBhMe 3uKw== MIME-Version: 1.0 Received: by 10.50.217.227 with SMTP id pb3mr4684081igc.28.1344947868431; Tue, 14 Aug 2012 05:37:48 -0700 (PDT) Received: by 10.64.141.36 with HTTP; Tue, 14 Aug 2012 05:37:48 -0700 (PDT) In-Reply-To: References: <50280D37.10109@moonspot.net> Date: Tue, 14 Aug 2012 14:37:48 +0200 Message-ID: To: Nikita Popov Cc: Brian Moon , PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [RFC] Generators From: alex.aulbach@gmail.com (Alex Aulbach) 2012/8/13 Nikita Popov : > * 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. Hm. I think this looks like a workaround over conceptual problems. The (in my eyes) "right" behavior would be to call a new instance of the generator if you rewind and destroy the current (= replace current generator with a new). I would prefer to say "this is not an real iterator"; if you want to make it an real iterator, then implement it yourself. Otherwise it's like "Ok, we have here a new type of function which looks enough like a function to be a function, which implements an iterator which looks enough like an iterator to be an iterator.". :) I also recommend to say, that generators aren't a good idea if used on resources, which can't be shared. For example: the file-read-example doesn't lock. To implement locking new functions or a new class is needed - hiding complexity. Generators are (in my opinion) really nice for things which are already in the memory. Not more or less. -- Alex Aulbach